首頁  >  文章  >  web前端  >  防止网站内容被小偷采集的js代码[原创]_javascript技巧

防止网站内容被小偷采集的js代码[原创]_javascript技巧

WBOY
WBOY原創
2016-05-16 19:25:581293瀏覽
防止网站内容被小偷采集的ASP代码
看了一下asp的,因为我的站是静态的所以就凑手写了个静态的javascript版的。
具体就不详细说明了:
欢迎讨论,原创转载请说明
复制代码 代码如下:

<script> <BR>function setCookie(name, value, expires, path, domain, secure) { <BR> var curCookie = name + "=" + escape(value) + <BR> ((expires) ? "; expires=" + expires.toGMTString() : "") + <BR> ((path) ? "; path=" + path : "/") + <BR> ((domain) ? "; domain=" + domain : "") + <BR> ((secure) ? "; secure" : "") <BR>document.cookie=curCookie; <BR> } <BR>function getCookie(name) { <BR> var prefix = name + "=" <BR> var cookieStartIndex = document.cookie.indexOf(prefix) <BR> if (cookieStartIndex == -1) <BR> return null <BR> var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length) <BR> if (cookieEndIndex == -1) <BR> cookieEndIndex = document.cookie.length <BR> return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)) <BR>} <br><br>var now = new Date() <BR>now.setTime(now.getTime() + 6*1000) <BR>var jb51num=10; <BR>var visits = getCookie("jb51") <BR>if (!visits) <BR> visits = 1 <BR>else <BR> visits = parseInt(visits) + 1 <BR>if (visits>parseInt(jb51num)){ <BR>alert('没有内容'); <BR>location.href='http://www.jb51.net'; <BR>} <BR>setCookie("jb51", visits, now) <BR></script>

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn