当前页面: 开发资料首页 → Javascript 专题 → JavaScript实例 用Cookie实现仅弹出一次窗口
摘要: JavaScript实例 用Cookie实现仅弹出一次窗口
              脚本说明:
              第一步:把如下代码加入<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()">