用Cookie实现仅弹出一次窗口
脚本说明:
第一步:把如下代码加入<head>区域中 复制内容到剪贴板
代码:
- <SCRIPT language="javascript"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- <!--<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- function openpopup(){<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- window.open("welcome.htm","","width=300,height=300")<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- function get_cookie(Name) {<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- var search = Name + "="<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- var returnvalue = "";<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- if (documents.cookie.length > 0) {<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- offset = documents.cookie.indexOf(search)<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- if (offset != -1) { // if cookie exists<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- offset += search.length<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- // set index of beginning of value<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- end = documents.cookie.indexOf(";", offset);<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- // set index of end of cookie value<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- if (end == -1)<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- end = documents.cookie.length;<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- returnvalue="/(documents.cookie.substring(offset," end))<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- return returnvalue;<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- function loadpopup(){<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- if (get_cookie('popped')=='){<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- openpopup()<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- documents.cookie="popped=yes"<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- //--><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- </SCRIPT>
复制代码
第二步:把<body>中内容改为:
复制内容到剪贴板
代码:
- <body bgcolor="#fef4d9" >
复制代码
|