大唐我是李元吉:这段程序可以用到任何程序里吗?

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 13:05:27
这里有什么参数是要根据其主程序修改的呢?
谢谢

我要做的是要保存当前页面的状态,在刷新后保持状态不变,所以要用到
Cookie操作,想把这段代码加进去,不知道要怎样衔接.
谢谢回答

function Cookie(document,name, hours, path, domain, secure)
{ // 保存Cookie
this.$document = document;
this.$name = name;
if(hours)
this.$expiration = new Date((new Date()).getTime() + hours * 3600000);
else this.$expiration = null;
if(path) this.$path = path;
else this.$path = null;
if(domain) this.$domain = domain;
else this.$domain = null;
if(secure) this.$secure = ture;
else this.$secure = false;
}//end funciton Cookie

Cookie.prototype.store = fuction()
{
var cookieval = "";
for (var prop in this){
if((prop.char.At(0) == '$') || ((typeof this[prop]) == 'function'))
continue;
if(cookieval != "")
cookieval += '&';
cookieval += prop + ':' + escape(this[prop]);
}
var cookie = this.$name + '=' + cookieval;
if(this.$expiration)
cookieval += '; expires=' + this.$expiration.toString();
if(this.$path)
cookieval += ';path=' + this.$path;
if (this.$domain)
cookieval += ';domain=' + this.$domain;
if (this.$secure)
cookieval += ';secural';
this.document.cookie = cookie;
}

Cookie.prototype.getCookie = fuction()
{
var allcookies = this.$document.cookie;
if(allcookies == "")
return false;
var start = allcookies.indexof(this.$name + '=');
if(start == -1)
return false;
start += this.$name.length + 1;
var end += allcookies.indexof(';' , start);
if (end == -1)
end += allcookies.length;
var cookieval = allcookis.substring(start , end);
var a = cookieval.split('&');
for(var i = 0; i <= a.length ; i++)
a[i] = a[i].split( ':' );
for(var i = 0; i <= a.length ; i ++)
this[a[i][0] = unescape(a[i][1]]);
return ture;
}

// -->
this.name = Tname;
和这个程序里的this.$name = name有冲突吗?