JS通过Cookie判断页面是否为首次打开

网络编程 发布日期:2024/10/5 浏览次数:1

正在浏览:JS通过Cookie判断页面是否为首次打开

废话不多说了,直接给大家贴代码了,本文写的不好还请各位大侠见谅。

JScript code:

function Cookie(key,value)
{
this.key=key;
if(value!=null)
{
this.value=escape(value);
}
this.expiresTime=null;
this.domain=null;
this.path="/";
this.secure=null;
}
Cookie.prototype.setValue=function(value){this.value=escape(value);}
Cookie.prototype.getValue=function(){return (this.value);}
Cookie.prototype.setExpiresTime=function(time){this.expiresTime=time;}
Cookie.prototype.getExpiresTime=function(){return this.expiresTime;}
Cookie.prototype.setDomain=function(domain){this.domain=domain;}
Cookie.prototype.getDomain=function(){return this.domain;}
Cookie.prototype.setPath=function(path){this.path=path;}
Cookie.prototype.getPath=function(){return this.path;}
Cookie.prototype.Write=function(v)
{
if(v!=null)
{
this.setValue(v);
}
var ck=this.key+"="+this.value;
if(this.expiresTime!=null)
{
try
{
ck+=";expires="+this.expiresTime.toUTCString();;
}
catch(err)
{
alert("expiresTime参数错误");
}
}
if(this.domain!=null)
{
ck+=";domain="+this.domain;
}
if(this.path!=null)
{
ck+=";path="+this.path;
}
if(this.secure!=null)
{
ck+=";secure";
}
document.cookie=ck;
}
Cookie.prototype.Read=function()
{
try
{
var cks=document.cookie.split("; ");
var i=0;
for(i=0;i <cks.length;i++)
{
var ck=cks[i];
var fields=ck.split("=");
if(fields[0]==this.key)
{
this.value=fields[1];
return (this.value);
}
}
return null;
}
catch(err)
{
alert("cookie读取错误");
return null;
}
}

HTML code:

<script type="text/javascript" src="/UploadFiles/2021-04-02/Cookie.js">

以上所述是小编给大家分享JS通过Cookie判断页面是否为首次打开的相关内容,希望对大家有所帮助。

几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。