首先将easyui的样式文件加入一个ID,这里命名为easyuiTheme,然后在样式文件下面加入一个JS文件

<script type="text/javascript" charset="UTF-8" src="jslib/jquery-easyui-1.2.5/jquery-1.7.1.min.js"></script>

<script type="text/javascript" charset="UTF-8" src="jslib/jquery.cookie.js"></script>

<link id="easyuiTheme" rel="stylesheet" type="text/css" href="jslib/jquery-easyui-1.2.5/themes/gray/easyui.css">
<script type="text/javascript" charset="UTF-8" src="jslib/changeEasyuiTheme.js"></script>
<link rel="stylesheet" type="text/css" href="jslib/jquery-easyui-1.2.5/themes/icon.css">
<script type="text/javascript" charset="UTF-8" src="jslib/jquery-easyui-1.2.5/jquery.easyui.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="jslib/jquery-easyui-1.2.5/locale/easyui-lang-zh_CN.js"></script>

changeEasyuiTheme.js文件的内容是

function changeThemeFun(themeName) {/* 更换主题 */
var $easyuiTheme = $('#easyuiTheme');
var url = $easyuiTheme.attr('href');
var href = url.substring(0, url.indexOf('themes')) + 'themes/' + themeName + '/easyui.css';
$easyuiTheme.attr('href', href);

var $iframe = $('iframe');
if ($iframe.length > 0) {
for ( var i = 0; i < $iframe.length; i++) {
var ifr = $iframe[i];
$(ifr).contents().find('#easyuiTheme').attr('href', href);
}
}

$.cookie('easyuiThemeName', themeName, {
expires : 7
});
};
if ($.cookie('easyuiThemeName')) {
changeThemeFun($.cookie('easyuiThemeName'));
}

jquery.cookie.js的内容是

jQuery.cookie = function (key, value, options) {

// key and value given, set cookie...
if (arguments.length > 1 && (value === null || typeof value !== "object")) {
options = jQuery.extend({}, options);

if (value === null) {
options.expires = -1;
}

if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}

return (document.cookie = [
encodeURIComponent(key), '=',
options.raw ? String(value) : encodeURIComponent(String(value)),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}

// key and possibly options given, get cookie...
options = value || {};
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

使用的时候

changeThemeFun('default');
changeThemeFun('gray');

easyui换主题,并记录在cookie的更多相关文章

  1. Cookie中图片的浏览记录与cookie读取servle时路径的设置(文字描述)

    public class ShowServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpSer ...

  2. js实用方法记录-简单cookie操作

    js实用方法记录-简单cookie操作 设置cookie:setCookie(名称,值,保存时间,保存域); 获取cookie:setCookie(名称); 移除cookie:setCookie(名称 ...

  3. Eclipse 换主题、皮肤、配色,换黑色主题护眼

    Eclipse写android代码时,默认的文本和框架都是白色,长时间使用,显得过于刺眼.这里介绍三种方法换黑色护眼配色. 1.系统设置里更改 2.从Eclipse Marketplace里下载主题 ...

  4. 2018-2-13-win10-uwp-切换主题

    原文:2018-2-13-win10-uwp-切换主题 title author date CreateTime categories win10 uwp 切换主题 lindexi 2018-2-13 ...

  5. 基于ElementUI的网站换主题的一些思考与实现

    前言 web应用程序,切换主题,给其换肤,是一个比较常见的需求. 如何能快速的切换主题色?(只有固定的一种皮肤) 如果又想把主题色切换为以前的呢?(有多种可切换的皮肤) 该以何种方式编写标签的css属 ...

  6. easyui更换主题之后出现validatebox的验证提示信息显示跑偏的解决方案

    在easyui中更换主题为非default的主题,有的主题会出现如下图所示的情况,验证提示信息的提示内容跑到了下面. 现在说下原因和解决方案: 原因:原因是easyui对某些主题没有进行这个样式的设置 ...

  7. sublime text2 换主题

    网上看到一款喜欢的主题,换掉初始的主题,感觉颜色浅一点会比较好看,看中了下面这款. 后来看到有在 github 上的人做的 ,这是地址 ,上面也有详细的如何更改的步骤,下面是我自己这里做个备份. 1. ...

  8. easy-ui JOB 及 小记录

    $:获取  $.ajax({             type: "POST" ,             url: "" ,             cont ...

  9. [转]jQuery EasyUI 扩展-- 主题(Themes)

    主题(Themes)允许您改变站点的外观和感观.使用主题可以节省设计的时间,让您腾出更多的时间进行开发.您也可以创建一个已有主题的子主题. 主题生成器(Theme Builder) jQuery UI ...

随机推荐

  1. About stats collected

    pg_class.relpages pg_class.reltuples仅仅是近似值,和实际数据会有点误差: 新建空表.首次insert对自己主动收集和更新统计信息,影响的表pg_class\pg_s ...

  2. [HTML5] Build Flexible HTML with HTMLTemplates using Slots and Web Components

    HTMLTemplates are part of the web components specification. In this lesson we will learn what are HT ...

  3. minic 类型声明与变量定义句型处理

    #include "token_define.h" //这个文件是用来处理句型的,对于算术表达式都是放在前面的那个头文件中来处理 typedef struct _handle_tr ...

  4. Joiner的用法

    Google Guava提供了Joiner类专门用来连接String. 譬如说有个String数组,里面有"a","b","c",我们可以通 ...

  5. cocos2d-x 托付模式的巧妙运用——附源代码(二)

    转载请注明出处:http://blog.csdn.net/hust_superman/article/details/38292265,谢谢. 继上一篇将了托付类的详细实现后.这篇来将一下怎样在游戏中 ...

  6. java检索文件时加入线程

    package xianChengSaomiao; import java.io.File; import java.util.ArrayList; import java.util.List; pu ...

  7. Core Data 更新某条指定记录数据

    一:流程 同样需要先查询出指定记录 更新指定记录 二:代码: //更新操作 - (void)updateThePersonData { NSFetchRequest *fetchRequest = [ ...

  8. js 数组分解 解构

    // ES5 a = list[0], rest = list.slice(1) // ES6 [a, ...rest] = list

  9. C++11: reference_wrapper

    https://oopscenities.net/2012/08/09/reference_wrapper/ Look at this piece of code: 1 2 3 4 5 6 7 8 9 ...

  10. 搭建 SMTP mail

    邮件协议需要配置client 端 和 server 端,在linux redhat 下 client 端: 使用linux 自带的Evolution,2.12.3, 主要配置在preferrence ...