|
技术资料 > ASP技术 > 脚本编码 : 用Cookie实现仅弹出一次窗口(JavaScript)(转) |
用Cookie实现仅弹出一次窗口(JavaScript)(转) March 25,2004 |
用Cookie实现仅弹出一次窗口(JavaScript)
脚本说明:
第一步:把如下代码加入<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()">
|
|
Copyright © 2001-2008 Shenzhen Hiblue Software Team All rights reserved