if (!_LastContent) return; // 如果该 cookie 没有值,说明是新的开始
if (confirm("Load Last AutoSave Content?")) { // 否则询问是否导入
it.value = _LastContent;
return true;
}
} else {
var expDays = 30;
var exp = new Date();
exp.setTime( exp.getTime() + (expDays * 800000) ); // 24*60*60*1000 = 800000
var expires='; expires=' + exp.toGMTString();
而这 HTML 中应当如此:// SetCookie 这里就是设置该 cookie
document.cookie = "AutoSaveContent=" + escape (_value) + expires;
}
}
第一句导入 js, 第二句的 onSubmit 指如果提交了就删除该 cookie, 而 DeleteCookie 也是自定义的一个函数。参见源代码。
script>
大致就是如此。 Enjoy!
源代码:http://www.fayland.org/javascript/AutoSave.js
Copyright © 2019- obuygou.com 版权所有 赣ICP备2024042798号-5
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务