<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<SCRIPT type=text/javascript>
function Set(Cookie_name)
{
var Then = new Date()
Then.setTime(Then.getTime() + 1*3600000 ) //小时
document.cookie = Cookie_name+"=true;expires="+ Then.toGMTString()
}
function Get(Cookie_name)
{
var cookieString = new String(document.cookie)
var cookieHeader = Cookie_name+"="
var beginPosition = cookieString.indexOf(cookieHeader)
if (beginPosition != -1) //cookie已经设置值,应该 不显示提示框
{
alert(Cookie_name+"返回"+cookieString.substring(beginPosition + cookieHeader.length));
}
else //cookie没有设置值,应该显示提示框
{
alert("Cookie 未找到!");
}
}
function Move(Cookie_name)
{
document.cookie = Cookie_name+"=;expires=Fri, 02-Jan-1970 00:00:00 GMT";
}
</SCRIPT>
<P>
<INPUT οnclick="Set('steven lu')" type=button value=设置cookie值><P>
<INPUT οnclick="Get('steven lu')" type=button value=查看cookie值><P>
<INPUT οnclick="Move('steven lu')" type=button value=清除cookie值><PRE></PRE>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<SCRIPT type=text/javascript>
function Set(Cookie_name)
{
var Then = new Date()
Then.setTime(Then.getTime() + 1*3600000 ) //小时
document.cookie = Cookie_name+"=true;expires="+ Then.toGMTString()
}
function Get(Cookie_name)
{
var cookieString = new String(document.cookie)
var cookieHeader = Cookie_name+"="
var beginPosition = cookieString.indexOf(cookieHeader)
if (beginPosition != -1) //cookie已经设置值,应该 不显示提示框
{
alert(Cookie_name+"返回"+cookieString.substring(beginPosition + cookieHeader.length));
}
else //cookie没有设置值,应该显示提示框
{
alert("Cookie 未找到!");
}
}
function Move(Cookie_name)
{
document.cookie = Cookie_name+"=;expires=Fri, 02-Jan-1970 00:00:00 GMT";
}
</SCRIPT>
<P>
<INPUT οnclick="Set('steven lu')" type=button value=设置cookie值><P>
<INPUT οnclick="Get('steven lu')" type=button value=查看cookie值><P>
<INPUT οnclick="Move('steven lu')" type=button value=清除cookie值><PRE></PRE>
</BODY>
</HTML>