打开 jquery.cookie.js文件:
找到 options.path
修改如下:
var pathStr='; path=' + options.path;
if($.browser.msie) {//如果是IE浏览器
pathStr='; path=' +window.location.pathname;
}
return (document.cookie = [
config.raw ? key : encodeURIComponent(key),
'=',
config.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? pathStr: '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
原理是:根据页面地址作为命名空间来写入cookie。这是IE的一个bug。IE8不会修复这个bug。