栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

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

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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 

HTML code:


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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/98475.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号