当前位置:首页 > 设计在线 > 网页设计 > Javascript > javascript实例 用Cookie实现仅弹出一次窗口

javascript实例 用Cookie实现仅弹出一次窗口

点击次数:17 次 发布日期:2008-11-26 22:19:18 作者:源代码网
源代码网推荐

脚本说明:
第一步:把如下代码加入<head>区域中
<SCRIPT language="JavaScript">
<!--


function openpopup(){
window.open("welcome.htm","","width=300,height=300")
}


function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function loadpopup(){
if (get_cookie("popped")==""){
openpopup()
document.cookie="popped=yes"
}
}

//-->
</SCRIPT>


第二步:把<body>中内容改为:
<body bgcolor="#fef4d9" onunload="loadpopup()">

 


源代码网供稿.
网友评论 (0)
会员中心
设计在线
本站推荐
设计在线之精华