Background:
Your Name:
Head Count:

只须将<body>改为

<body bgcolor="white" text="black" link="#003333" alink="#ffff00" vlink="#336633"

onLoad="

for (i=0; i &lt; 3; i++)

if (data[i] != null) document.forms[0].elements[i].value = data[i];

if (data[0] != null)

document.bgColor=data[0]; // set background colour

">                

并将如下代码加入<body>与</body>区即可:

<script language="JavaScript">

<!-- Hide from older browsers

var pham = document.cookie.split("; "); // break cookie into array of pham

function getCookie(name) {

for (i=0; i < pham.length; i++) {

nextbite = pham[i].split("="); // break into name and value

if (nextbite[0] == name) // if name matches

return unescape(nextbite[1]); // return value

}

return null; // if no match return null

}

var today = new Date();

var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days

function setCookie(name, value) { // use: setCookie("name", value);

if (value != null && value != "")

document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();

pham = document.cookie.split("; "); // update cookie pham

}

var userData = getCookie("userData") || "white!Visitor!1"; // retrieve values or use default

var data = userData.split("!"); // convert cookie value to array

// Stop hiding -->

</script>

 

<blockquote>

<form name="cookieTest" method="post">

<div align="center"><center><table border="0" bgcolor="#000000" cellpadding="5"

cellspacing="0">

<tr>

<th align="left"><font face="Verdana" size="2" color="#FFFFFF">Background: </font></th>

<td><font face="Verdana" size="2" color="#FFFFFF"><input name="data0" type="text"

value="white" size="30"></font></td>

</tr>

<tr>

<th align="left"><font face="Verdana" size="2" color="#FFFFFF">Your Name: </font></th>

<td><font face="Verdana" size="2" color="#FFFFFF"><input name="data1" type="text"

value="Traveller" size="30"></font></td>

</tr>

<tr>

<th align="left"><font face="Verdana" size="2" color="#FFFFFF">Head Count: </font></th>

<td><font face="Verdana" size="2" color="#FFFFFF"><input name="data2" type="text"

value="1" size="30"></font></td>

</tr>

<tr bgcolor="#003333">

<td align="right" colspan="2" bgcolor="#000000"><input type="button" value="Execute"

onClick="

with (this.form) {

data[0] = data0.value; // if you want to add another variable

data[1] = data1.value; // just use data[3] or higher

data[2] = data2.value; // you can do this anywhere on the page.

}

setCookie('userData', data.join('!')); // cookie will store any length array

history.go(0);"></td>

</tr>

</table>

</center></div>

</form>

</blockquote>

<<前一教程     后一教程>>             回主页

访问人数