程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> ASP技巧 >> 利用cookie收藏網站

利用cookie收藏網站

編輯:ASP技巧

不用每次都詢問別人是否收藏,煩!
<SCRipT LANGUAGE="JavaScript">
<!-- Begin
var expDays = 100;
url = "http://softet.6to23.com";
title = "Come on";
function GetCookIE (name) { 
var arg = name + "="; 
var alen = arg.length; 
var clen = document.cookIE.length; 
var i = 0; 
while (i < clen) {   
var j = i + alen;   
if (document.cookIE.substring(i, j) == arg)     
return getCookIEVal (j);   
i = document.cookIE.indexOf(" ", i) + 1;   
if (i == 0) break;  

return null;
}
function SetCookIE (name, value) { 
var argv = SetCookIE.arguments; 
var argc = SetCookIE.arguments.length; 
var expires = (argc > 2) ? argv[2] : null; 
var path = (argc > 3) ? argv[3] : null; 
var domain = (argc > 4) ? argv[4] : null; 
var secure = (argc > 5) ? argv[5] : false; 
document.cookIE = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) + 
((domain == null) ? "" : ("; domain=" + domain)) +   
((secure == true) ? "; secure" : "");
}
function DeleteCookIE (name) { 
var exp = new Date(); 
exp.setTime (exp.getTime() - 1); 
var cval = GetCookIE (name); 
document.cookIE = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookIE('count')
if(count == null) {
SetCookIE('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookIE('count')
SetCookIE('count',newcount,exp)
return count
   }
}
function getCookIEVal(offset) {
var endstr = document.cookIE.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookIE.length;
return unescape(document.cookIE.substring(offset, endstr));
}

function checkCount() {
var count = GetCookIE('count');
if (count == null) {
count=1;
SetCookIE('count', count, exp);

if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
window.external.AddFavorite (url,title);
}
else {
var msg = "Don't forget to bookmark us!";
if(navigator.appName == "Netscape") msg += "  (CTRL-D)";
alert(msg);
   }
}
else {
count++;
SetCookIE('count', count, exp);
   }
}
checkCount();
//  End -->
</script>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved