JavaScript操作cookie
以下操作cookie在Firefox和Safari中测试成功,在IE中失败(读取、获取,改写,设置)。
经过反复测试,发现把http://127.0.0.1改为http://localhost之后,IE中也可以正常运行。
function getCookie(c_name) {
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + "=");
if (c_start != -1) {
c_start = c_start + c_name.length + 1;
c_end = document.cookie.indexOf(";", c_start);
if (c_end == -1) c_end = document.cookie.length;
return (document.cookie.substring(c_start, c_end));
}
}
return ""
}
function setCookie(c_name, value, expiredays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + expiredays);
document.cookie = c_name + "=" + value + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()) + ";path=/";
;
}
function checkCookie() {
master_headertop_narrow_show = getCookie('master_headertop_narrow_show')
alert(master_headertop_narrow_show); //////
if (master_headertop_narrow_show != null && master_headertop_narrow_show != "") {
if (master_headertop_narrow_show == 'true') {
var master_headertop = document.getElementById('master_headertop');
if (master_headertop)
master_headertop.style.display = 'none';
var master_headertop_narrow = document.getElementById('master_headertop_narrow');
if (master_headertop_narrow)
master_headertop_narrow.style.display = 'block';
}
}
}
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· Blazor Hybrid适配到HarmonyOS系统
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 解决跨域问题的这6种方案,真香!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
· 分享4款.NET开源、免费、实用的商城系统