1
我创建了一个带有选择输入的页面来更改正在使用的jQuery UI主题。当主题被改变时,它被存储在一个cookie中。加载页面时,如果cookie存在,主题将被恢复,否则会加载默认主题。浏览器 - 强制重新加载删除Cookie?
当我使用F5刷新页面时,我的代码确实有效,但如果我使用Ctrl + F5强制完成重新加载,则不会。这是我的代码中的问题,还是它的正常效果?
这里是我的代码,如果需要的话:
(function($) {
$(function() {
var $themeSelect = $('#themeSelect');
var initialTheme = $.cookie('theme');
$themeSelect.on('change', function() {
var dir = 'jQueryUI/css/' + $themeSelect.val();
$('#uiThemeA').attr('href', dir + '/jquery-ui.min.css');
$('#uiThemeB').attr('href', dir + '/jquery.ui.theme.css');
$.cookie('theme', $themeSelect.val());
});
if(initialTheme !== undefined) {
$themeSelect.children().each(function(index, element) {
var $element = $(element);
if($element.attr('selected')) {
$element.removeAttr('selected');
}
if($element.attr('value') === initialTheme) {
$element.attr('selected');
}
}).trigger('change');
} else {
$.cookie('theme', $themeSelect.val());
}
});
})(jQuery);
感谢您的帮助!