用Cookie实现仅弹出一次窗口
时间:2007-02-17 来源:PHP爱好者
脚本说明:
第一步:把如下代码加入<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()
php爱好者站 http://www.phpfans.net 网页特效|网页模板
第一步:把如下代码加入<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()
php爱好者站 http://www.phpfans.net 网页特效|网页模板
相关阅读 更多 +