範例

將以下程式拷貝回您的網頁

<script language="JavaScript">
<!-- Hide this script from old browsers --
var whichVersion = navigator.appVersion;
var platform = "";
var netscapev = "";
var i = 1;
if (whichVersion.substring(0,3) == "2.0") {
netscapev="2"
}
else if (whichVersion.substring(0,3) == "3.0") {
netscapev="3"
}
else
{
netscapev="1"
}
while (i < whichVersion.length) {
if (whichVersion.substring(i,i+1) == "(") {
if (whichVersion.substring(i+1,i+4) == "Mac") {
platform="Mac";
}
else if (whichVersion.substring(i+1,i+6) == "Win16") {
platform="Win";
}
else if (whichVersion.substring(i+1,i+6) == "Win95") {
platform="Win95";
}
else if (whichVersion.substring(i+1,i+6) == "WinNT") {
platform="WinNT";
}
else {
platform = "UNIX";
}
break;
}
i = i + 1;
}
// -- End Hiding Here -->
</script>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<CENTER>
<script language="JavaScript">
<!-- Hide this script from old browsers --
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 = (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 setLastHereOnCookie () {
var rightNow = new Date()
var expdate = new Date()
expdate.setTime (expdate.getTime() + 60*(24 * 60 * 60 * 1000)) // dead in 2 months
SetCookie ("lastHereOn", rightNow.getTime(), expdate, "/")
}
var lastVisit = GetCookie("lastHereOn")
var htm = '<table width=10 cellspacing=0 cellpadding=2 border=0><tr><td valign=top rowspan=4 width=200></a></td>'
Src='<tr><td width=300><br></td></tr><td width=10></td></tr><tr><td width=300><table width=300 cellspacing=0 cellpadding=3 border=0><tr><td width=1></td><td width=299>';
if (platform == "Win95" && netscapev=="2") {
htm += Src +"Netscape 2.0 and Windows 95";
}
else if (platform == "Win95" && netscapev=="3") {
htm += Src +"Netscape 3.0 and Windows 95";
}
else if (platform == "Mac" && netscapev=="2") {
htm += Src +"Netscape 2.0 and Macintosh";
}
else if (platform == "Mac" && netscapev=="3") {
htm += Src +"Netscape 3.0 and Macintosh";
}
else if (platform == "WinNT" && netscapev=="2") {
htm += Src +"Netscape 2.0 and Windows NT";
}
else if (platform == "WinNT" && netscapev=="3") {
htm += Src +"Netscape 3.0 and Windows NT";
}
else if (platform == "UNIX" && netscapev=="2") {
htm += Src +"Netscape 2.0 and UNIX";
}
else if (platform == "UNIX" && netscapev=="3") {
htm += Src +"Netscape 2.0 and UNIX";
}



else if (platform == "Win" && netscapev=="2") {



htm += Src +"Netscape 2.0 and Windows 3.1";



}



else if (platform == "Win" && netscapev=="3") {



htm += Src +"Netscape 3.0 and Windows 3.1";



}



else {



htm += Src;



}















htm += "</td></tr><tr><td width=1></td><td width=299>";







if (lastVisit == null) {



htm += "最近二個月內沒有您來訪記錄."



}



else {



var exp = 960201



var proc = 960001



var nut = 960001



var news = 960401



var sand = 960401



var soap = 960401







// mac getTime() but workaround, when they fix it this will be wrong...be vigilant



if (platform == "Mac") {



lastVisit = lastVisit - (24 * 60 * 60 * 1000) // getTime() one day off on Mac



}



htm += "您最後一次來訪是在<br><b>"



lastVisit = 1 * lastVisit // integerize that stringy cookie



var lastHereFormatting = new Date(lastVisit); // Date-i-fy that number



var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()



var lastHereInDateFormat = "" + lastHereFormatting; // Gotta use substring functions



var dayOfWeek = lastHereInDateFormat.substring(0,3)



var dateMonth = lastHereInDateFormat.substring(4,11)



var timeOfDay = lastHereInDateFormat.substring(11,16)



var year = lastHereInDateFormat.substring(23,25)







htm += dayOfWeek + ", " + dateMonth + " at " + timeOfDay // display



htm += "</b>,"



var noChange=0



if (intLastVisit < exp) {



noChange = 1



Src = '<a href="java1.htm">Java</a> section has been updated'



htm += "<br>Our " + Src



}



if (intLastVisit < proc) {



noChange = 1



Src = '<a href="h2s1.htm">Clients</a> section has been updated'



htm += "<br>Our " + Src



}



if (intLastVisit < nut) {



noChange = 1



Src = '<a href="h6s1.htm">Search</a> section has been updated'



htm += "<br>Our " + Src



}



if (intLastVisit < sand) {



noChange = 1



Src = '<a href="h7s1.htm">Press release</a> section has been updated'



htm += "<br>Our " + Src



}



if (intLastVisit < soap) {



noChange = 1



Src = '<a href="h8s1.htm">Job</a> section has been updated'



htm += "<br>Our " + Src



}



if (intLastVisit < news) {



noChange = 1



Src = '<a href="h9s1.htm">CGI</a> section has been updated'



htm += "<br>Our " + Src



}



if (noChange == 0) {



htm += "<br>本站已有做更新 ... enjoy"



}



}











setLastHereOnCookie()







htm += "</td></tr><tr><td width=1></td><td width=299>"



Src = '</td></tr>'



htm += Src + "</table></tr></table>";







document.write(htm)








// -- End Hiding Here -->
</script>

<BR>

<BR>

<BR>

<BR>