• 爱情文章
  • 亲情文章
  • 友情文章
  • 生活随笔
  • 校园文章
  • 经典文章
  • 人生哲理
  • 励志文章
  • 搞笑文章
  • 心情日记
  • 英语文章
  • 范文大全
  • 作文大全
  • 新闻阅读
  • 当前位置: 山茶花美文网 > 心情日记 > 正文

    JS通过Cookie判断页面是否为首次打开:用JS在html页面实现打印功能

    时间:2020-03-30来源:山茶花美文网 本文已影响 山茶花美文网手机站

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

    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
    • 爱情文章
    • 亲情文章
    • 友情文章
    • 随笔
    • 哲理
    • 励志
    • 范文大全