📄 test.htm
字号:
<html>
<head>
<script>
var testid;//保存DIV变量
//页面载入初始化并检查COOKIE
function init(){
testid = document.getElementById("test");
checkcookie();
}
//关闭并写入COOKIE
function closetest()
{
testid.style.display="none";
writecookie();
}
//检查COOKIE
function checkcookie()
{
var cookiearray=document.cookie.split("=");
if(cookiearray[0]!=null&&cookiearray[1]!=null)
{
testid.style.display="none";
}
}
//写COOKIE
function writecookie()
{
var date = new Date();
date.setTime(date.getTime()+10000);//设置过期时间(这里十秒)
var expirestr = date.toGMTString();
document.cookie = "cookiename=cookievalue;expires="+expirestr;
}
</script>
</head>
<body onload="init()">
<p>test点击后刷新在设定的时间内不会出现。这里DIV我直接写在页面里刷新会看到再消失。你写在JAVASCRIPT里就行了。</p>
<div id="test" onclick="closetest()" style="position: absolute; left: 155px; top: 132px;
width: 27px; height: 19px; z-index: 2;border:2px #00f;">
点击消失
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -