摘要:用于判斷用戶是否首次進入網(wǎng)站下面代碼需要在服務器下調試參數(shù)錯誤讀取錯誤用法第一次加載刷新
用于判斷用戶是否首次進入網(wǎng)站
下面代碼需要在服務器下調試
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) { console.log("expiresTime參數(shù)錯誤"); } } 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) { console.log("cookie讀取錯誤"); return null; } }
用法
var ck=new Cookie("HasLoaded"); if(ck.Read()==null){ console.log("第一次加載"); var dd = new Date(); dd = new Date(dd.getYear() + 1900, dd.getMonth(), dd.getDate()); dd.setDate(dd.getDate() + 365); ck.setExpiresTime(dd); ck.Write("true"); } else{ console.log("刷新"); }
文章版權歸作者所有,未經(jīng)允許請勿轉載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉載請注明本文地址:http://www.ezyhdfw.cn/yun/82714.html
摘要:系列文章請查看超詳細的面試題總結一之基礎知識篇超詳細的面試題總結二之基礎知識篇超詳細的面試題總結三之集合篇常見問題下面的都是自己之前在學習的時候總結的,對于鞏固的基礎知識應該有很大幫助。注意多線程的并發(fā)的讀寫類屬性會導致數(shù)據(jù)不同步。 系列文章請查看: 超詳細的Java面試題總結(一)之Java基礎知識篇 超詳細的Java面試題總結(二)之Java基礎知識篇 超詳細的Java面試題總結(...
摘要:當斷點被執(zhí)行到時,你就可以查看右邊的調用棧了,很容易就找到這個地方這個也是一個定時執(zhí)行,不過他只執(zhí)行一次,相當于定時炸彈。本文僅用于交流學習,請勿用于非法用途,后果自負首發(fā)地址請求網(wǎng)頁時,怎么給我返回了一段代碼 今天給大家?guī)淼氖且粋€論壇網(wǎng)站,牛仔俱樂部-努比亞社區(qū), 網(wǎng)址為:https://bbs.nubia.cn/ showImg(https://segmentfault.com/...
摘要:使用這種方案攔截的網(wǎng)絡請求造成的問題就是請求數(shù)據(jù)被清空,還是所為,看源碼主要看代碼中間那兩句注釋,大致的意思就是不會在進程間通信發(fā)送的。如何解決終極思路就是雖然的會在進程間通信時被丟棄,但不會。 github地址:JXBWKWebView,如果覺得項目不錯可以點個star支持一下,謝謝~ 前言 目前iOS系統(tǒng)已經(jīng)更新到iOS11,大多數(shù)項目向下兼容最多兼容到iOS8,因此,在項目中對...
摘要:使用這種方案攔截的網(wǎng)絡請求造成的問題就是請求數(shù)據(jù)被清空,還是所為,看源碼主要看代碼中間那兩句注釋,大致的意思就是不會在進程間通信發(fā)送的。如何解決終極思路就是雖然的會在進程間通信時被丟棄,但不會。 github地址:JXBWKWebView,如果覺得項目不錯可以點個star支持一下,謝謝~ 前言 目前iOS系統(tǒng)已經(jīng)更新到iOS11,大多數(shù)項目向下兼容最多兼容到iOS8,因此,在項目中對...
閱讀 3322·2023-04-26 03:06
閱讀 3747·2021-11-22 09:34
閱讀 1204·2021-10-08 10:05
閱讀 3162·2021-09-22 15:53
閱讀 3621·2021-09-14 18:05
閱讀 1536·2021-08-05 09:56
閱讀 2052·2019-08-30 15:56
閱讀 2174·2019-08-29 11:02