easyui动态切换主题
easyui换主题,并记录在cookie
首先将easyui的样式文件加入一个ID,这里命名为easyuiTheme,然后在样式文件下面加入一个JS文件
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');
if ((′iframe′);if(iframe.length > 0) {
for ( var i = 0; i < $iframe.length; i++) {
var ifr = $iframe[i];
$(ifr).contents().find(’#easyuiTheme’).attr(‘href’, href);
}
}
KaTeX parse error: Expected 'EOF', got '}' at position 57: …xpires : 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笔记4:实现表格内combobox数据的动态切换(getEditor的使用)
- javascript实现css主题样式切换;动态改变引入的css文件;
- Android动态切换主题
- Easyui笔记4:实现表格内combobox数据的动态切换(getEditor的使用)
- laravel4通过控制视图模板路劲来动态切换主题
- asp.net动态切换主题
- easyui切换主题
- Easyui笔记4:实现表格内combobox数据的动态切换(getEditor的使用)
- ext 动态切换主题的语法
- asp.net动态切换主题
- asp.net mvc + easyui 页面主题切换
- Easyui笔记4:实现表格内combobox数据的动态切换(getEditor的使用)
- android 应用动态切换主题
- Android应用主题动态切换
- [转] ASP.NET 2.0 主题的动态切换
- Android动态切换主题
- Android 主题动态切换框架:Prism
- Easyui笔记4:实现表格内combobox数据的动态切换(getEditor的使用)
- ASP.NET 2.0 Personal Web Site Starter Kit 主题的动态切换(增加八种主题)
- Easyui笔记4:实现表格内combobox数据的动态切换(getEditor的使用)