我有不工作的 cookie 代码不知道是什么问题。此代码在另一个脚本中工作,但不在其中。
代码:
function get_cookie(Name) {
var search = Name + "=";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
// cookie exist, update expiry date of the same cookie
if (offset != -1) {
cookie_info = document.cookie.split('=');
cookie_info = cookie_info[0]+"=" + cookie_info[1];
// add 30 days expiry
var date = new Date();
date.setTime(date.getTime()+(30*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
cookie_info += expires + ";path=/";
document.cookie = cookie_info;
}
}}
function loadCokie() {
if (get_cookie('popup')=='') {
alert("hello");
document.cookie="popup=yes"
}
}
提前谢谢