81,114
社区成员
发帖
与我相关
我的任务
分享<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<script Language="JavaScript">
function setCookie(name, value) {
var exp = new Date();
exp.setTime(exp.getTime() + 20 * 1000);
//cookie 保存20秒
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
document.cookie = name + "=" + value;
}
function getCookie(name) {
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
if (arr != null)
return unescape(arr[2]);
return '';
}
function delCookie(name)//删除cookie
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = getCookie(name);
if (cval != null)
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}
function hasEmpty(){ //判断数组元素是否还存在没存到cookie里的。
for(i=0;i<9;i++){
if(getCookie(i) == ''){
return true;
}
}
}
tips = new Array(9);
tips[0] = "金麟岂是池中物(1)";
tips[1] = "一遇风云变化龙(2)";
tips[2] = "左青龙(3)";
tips[3] = "右白虎(4)";
tips[4] = "前朱雀(5)";
tips[5] = "后玄武(6)";
tips[6] = "老牛在腰间(7)";
tips[7] = "床前明月光(8)";
tips[8] = "飞流直下三千尺(9)";
while(hasEmpty()) {
index = Math.floor(Math.random() * tips.length);
if (getCookie(index) == '') {
setCookie(index, index);
document.write("<FONT SIZE=8 COLOR=DARKBLUE>" + tips[index] + "</FONT>");
break;
}
}
</Script>
</body>
</html>