我要的效果是,第一次打开这个页面,出现提示对话框,点击 不再提示 关闭后,刷新网页或关闭网页下次打开不再出现。为什么我下面的代码不行呢?谢谢大家伙了
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function setCookie(value){
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = "myCookies="+ escape (value) + ";expires=" + exp.toGMTString();
document.getElementById("myDiv").style.display="none";
}
function getCookies(){
var cookieStr = document.cookie;
var cookieValue = "noCookies";
if(cookieStr != "" && cookieStr!=null){
var cookieValueArray = cookieStr.split(";");
for(var i=0;i<cookieValueArray.length;i++){
if(cookieValueArray[i].split("=")[0]=="myCookies"){
cookieValue = cookieValueArray[i].split("=")[1];
}
}
}
return cookieValue;
}
function verifyCookie(){
var alertCookieStr = getCookies();
if(alertCookieStr == "closeWindows"){
document.getElementById("myDiv").style.display="none";
}
}
</script> </head>
<body onLoad="verifyCookie();">
<div id="myDiv" style="width:300px; height:100px; line-height: 100px; text-align: center; border: 1px solid;">
这是弹出div <a href="javascript:void(0)" onclick='setCookie("closeWindows");'>不再提示</a>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function setCookie(value){
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = "myCookies="+ escape (value) + ";expires=" + exp.toGMTString();
document.getElementById("myDiv").style.display="none";
}
function getCookies(){
var cookieStr = document.cookie;
var cookieValue = "noCookies";
if(cookieStr != "" && cookieStr!=null){
var cookieValueArray = cookieStr.split(";");
for(var i=0;i<cookieValueArray.length;i++){
if(cookieValueArray[i].split("=")[0]=="myCookies"){
cookieValue = cookieValueArray[i].split("=")[1];
}
}
}
return cookieValue;
}
function verifyCookie(){
var alertCookieStr = getCookies();
if(alertCookieStr == "closeWindows"){
document.getElementById("myDiv").style.display="none";
}
}
</script> </head>
<body onLoad="verifyCookie();">
<div id="myDiv" style="width:300px; height:100px; line-height: 100px; text-align: center; border: 1px solid;">
这是弹出div <a href="javascript:void(0)" onclick='setCookie("closeWindows");'>不再提示</a>
</div>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货