很简单的代码.直接加在你的页面中就可以了,当然也可以存为JS来调用,以方便以后修改!

<script language="javascript">
//写入COOKIE
function setCookie(name,value){ 
var Days = 1; 
var exp = new Date(); 
exp.setTime(exp.getTime() + Days*24*60*60*1000); 
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 
}

//读取COOKIE
function getCookie(name){ 
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); 
if(arr=document.cookie.match(reg)) return unescape(arr[2]); 
else return null; 
}

window.attachEvent("onload", function(){ 
if (getCookie("popWin")) return false; 
var o = document.getElementsByTagName("a"); 
for (var i=0; i<o.length; i++){
    o[i].attachEvent("onclick", function(){ 
      if (!getCookie("popWin")){ 
        setCookie("popWin", "true"); 
        window.open("http://www.ymgod.com", "popWin", "toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes"); 
        window.focus();
        } 
      }); 
    } 
});
</script>

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注