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 = 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;
}; <div data-options="iconCls:'icon-theme'">
<span>主题切换</span>
<div style="width:100px;">
<div class="theme" name="default" onclick="changeThemeFun('black')">black</div>
<div class="theme" name="bootstrap" onclick="changeThemeFun('bootstrap')">bootstrap</div>
<div class="theme" name="black" onclick="changeThemeFun('cupertino')">cupertino</div>
<div class="theme" name="gray" onclick="changeThemeFun('default')">default</div>
<div class="theme" name="metro" onclick="changeThemeFun('gray')">gray</div>
<div class="theme" name="metro" onclick="changeThemeFun('sunny')">sunny</div>
<div class="menu-sep"></div>
<div class="theme" name="default" onclick="changeThemeFun('metro')">metro</div>
<div class="theme" name="bootstrap" onclick="changeThemeFun('metro-blue')">metro-blue</div>
<div class="theme" name="black" onclick="changeThemeFun('metro-gray')">metro-gray</div>
<div class="theme" name="gray" onclick="changeThemeFun('metro-green')">metro-green</div>
<div class="theme" name="metro" onclick="changeThemeFun('metro-red')">metro-red</div>
<div class="theme" name="metro" onclick="changeThemeFun('pepper-grinder")">pepper-grinder</div>
</div>
</div>easyui主题
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 = 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;
}; <div data-options="iconCls:'icon-theme'">
<span>主题切换</span>
<div style="width:100px;">
<div class="theme" name="default" onclick="changeThemeFun('black')">black</div>
<div class="theme" name="bootstrap" onclick="changeThemeFun('bootstrap')">bootstrap</div>
<div class="theme" name="black" onclick="changeThemeFun('cupertino')">cupertino</div>
<div class="theme" name="gray" onclick="changeThemeFun('default')">default</div>
<div class="theme" name="metro" onclick="changeThemeFun('gray')">gray</div>
<div class="theme" name="metro" onclick="changeThemeFun('sunny')">sunny</div>
<div class="menu-sep"></div>
<div class="theme" name="default" onclick="changeThemeFun('metro')">metro</div>
<div class="theme" name="bootstrap" onclick="changeThemeFun('metro-blue')">metro-blue</div>
<div class="theme" name="black" onclick="changeThemeFun('metro-gray')">metro-gray</div>
<div class="theme" name="gray" onclick="changeThemeFun('metro-green')">metro-green</div>
<div class="theme" name="metro" onclick="changeThemeFun('metro-red')">metro-red</div>
<div class="theme" name="metro" onclick="changeThemeFun('pepper-grinder")">pepper-grinder</div>
</div>
</div>easyui主题
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货