範例
將以下程式拷貝回您的網頁
<SCRIPT LANGUAGE="JavaScript">
<!--hiding
//**************************************************************************
// THIS WAS highly modified BY unixdown
// http://homepage.dave-world.net/~zweber/unix.html
// zweber@mail.dave-world.net
// Please give me credit for this script
//**************************************************************************
function getCookieVal (offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
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 = (2 < argc) ? argv[2] : null;
var path = (3 < argc) ? argv[3] : null;
var domain = (4 < argc) ? argv[4] : null;
var secure = (5 < argc) ? 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 to diplay info
// by unixdown (zweber@mail.dave-world.net)
function DisplayInfo()
{
var expdate = new Date();
var visit;
// Set expiration date to a year from now.
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
if(!(visit = GetCookie("visit")))
visit = 0;
visit++;
SetCookie("visit", visit, expdate, "/", null, false);
var message;
if(visit == 1)
message=" 歡迎";
if(visit== 2)
message=" 嗨";
if(visit == 3)
message=" 很酷的網站吧!";
if(visit == 4)
message=" 很嚴肅嗎?";
if(visit == 5)
message=" 找到你想要的資料了?!";
if(visit == 6)
message=" 有時間嗎?!";
if(visit == 7)
message=" 還想找些什麼程式呢?";
if(visit == 8)
message=" 你都不睡的嗎?";
if(visit == 9)
message=" 優秀的人物!!!";
if(visit >= 10)
message=" 這一定是個很棒的網站吧!?!^_^";
alert("\n"+"你來訪這一頁,這是第 \n"
+" "+visit+"\n"
+" 次."+"\n"+"\n"
+message);
}
//end hiding-->
</Script>
<body background="13.jpg" onload="DisplayInfo()">