关闭当前页面 弹出新页面

<script language="JavaScript" type="text/javascript"> 

function getsec(str)
{

   var str1=str.substring(1,str.length)*1;
   var str2=str.substring(0,1);
   if (str2=="s")
   {
        return str1*1000;
   }
   else if (str2=="h")
   {
       return str1*60*60*1000;
   }
   else if (str2=="d")
   {
       return str1*24*60*60*1000;
   }
}

    
    if(document.cookie.indexOf('CookieName')==-1){
/*浏览器关闭事件*/
    window.onbeforeunload = onbeforeunload_handler;   
    function onbeforeunload_handler(){   
        var gt = unescape('%3e');
        var popup = null;
        var over = "Launch Pop-up Navigator";
        popup = window.open('/swt/', 'popupnav', 'width=950,height=650,resizable=1,scrollbars=auto');
        if (popup != null) {
            if (popup.opener == null) {
                popup.opener = self; 
            }
                popup.location.href = '/swt/';
        }

    }
//这是有设定过期时间的使用示例:
//s20是代表20秒
//h是指小时,如12小时则是:h12
//d是天数,30天则:d30
//具体看函数 getsec()
    var strsec = getsec('s5');
    var exp = new Date();
    exp.setTime(exp.getTime() + strsec*1);

    document.cookie = "CookieName = cookieValue;expires=" + exp.toGMTString();
    }
    
    
    
  var strCookie=document.cookie; 
  document.write(strCookie); 

  
  

</script> 

 

 

可能会被浏览器 拦截

posted @ 2014-04-04 15:28  撑着破伞去看雨  阅读(184)  评论(0)    收藏  举报