destoon實現(xiàn)底部添加你是第幾位訪問者的方法
經(jīng)常會看到一些網(wǎng)站有類似“您是第位訪客”字樣的計數(shù)統(tǒng)計,這里我們來實現(xiàn)把這個統(tǒng)計功能添加到destoon的底部,顯示“你是第幾問訪問者”的效果。此處的計數(shù)器與網(wǎng)站流量統(tǒng)計有區(qū)別,記錄的是刷新次數(shù),并不是真實記錄訪問者的IP,對于需要真正進(jìn)行統(tǒng)計的朋友可以進(jìn)一步完善代碼以滿足自身需求。
下面就來說一下具體的實現(xiàn)方法:
打開底部footer.htm的文件,找到<a href="{$MODULE[1][linkurl]}" rel="external nofollow" >返回首頁</a>,在后面加上這段代碼:
<script language="JavaScript"> <!-- var caution = false function setCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "") if (!caution || (name + "=" + escape(value)).length <= 4000) document.cookie = curCookie else if (confirm("Cookie exceeds 4KB and will be cut!")) document.cookie = curCookie } function getCookie(name) { var prefix = name + "=" var cookieStartIndex = document.cookie.indexOf(prefix) if (cookieStartIndex == -1) return null var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length) if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length return (document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)) } function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT" } } function fixDate(date) { var base = new Date(0) var skew = base.getTime() if (skew > 0) date.setTime(date.getTime() - skew) } var now = new Date() fixDate(now) now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000) var visits = getCookie("counter") if (!visits) visits = 1 else visits = parseInt(visits) + 1 setCookie("counter", visits, now) document.write("您是第 " + visits + " 個來到本站訪客") // --> </script>
- destoon調(diào)用discuz論壇中帶圖片帖子的實現(xiàn)方法
- destoon調(diào)用企業(yè)會員公司形象圖片的實現(xiàn)方法
- destoon實現(xiàn)調(diào)用當(dāng)前欄目分類及子分類和三級分類的方法
- destoon實現(xiàn)VIP排名一直在前面排序的方法
- Destoon實現(xiàn)多表查詢示例
- destoon首頁調(diào)用求購供應(yīng)信息的地區(qū)名稱的方法
- destoon實現(xiàn)調(diào)用熱門關(guān)鍵字的方法
- destoon實現(xiàn)資訊信息前面調(diào)用它所屬分類的方法
- destoon實現(xiàn)首頁顯示供應(yīng)、企業(yè)、資訊條數(shù)的方法
- destoon實現(xiàn)公司新聞詳細(xì)頁添加評論功能的方法
- destoon數(shù)據(jù)庫表說明匯總
- destoon切換城市后實現(xiàn)logo旁邊顯示地區(qū)名稱的方法
相關(guān)文章
php while循環(huán)得到循環(huán)次數(shù)
在for循環(huán)中,我們很容易得到循環(huán)次數(shù),因為是作為條件出現(xiàn)的。在while也可以得到,如下:2013-10-10visual studio code 調(diào)試php方法(圖文詳解)
本篇文章主要介紹了visual studio code 調(diào)試php方法(圖文詳解),具有一定的參考價值,有興趣的可以了解一下2017-09-09