代码如下<script LANGUAGE="JavaScript"> 
<!-- 
function opennew(){
window.open ("./hp3.php?id=2","","height=800,width=1000,top=0,left=0,toolbar=yes,menubar=yes,scrollbars=yes,depended=yes,resizable=yes,location=yes,status=yes");
}
//--> 
</script>
<body  onkeypress="<?php if($_COOKIE['picid']-1 == 22) echo $gotourla;else if($_COOKIE['picid']-1 == 12) echo $gotourld;else if($_COOKIE['picid']-1 ==17)echo $gotourlw;else if($_COOKIE['picid']-1 == 28 ) echo $gotourlq; ?>" onbeforeUnload="<?php if($_COOKIE['picid']-1 != 12 && $_COOKIE['picid']-1 != 17 && $_COOKIE['picid']-1 !=22 && $_COOKIE['picid']-1 != 28 )echo "opennew()";?>">问题
这样的代码在本机上测试,,可以在关掉窗口的时候打开hp3.php页面,而把它传到空间上,我再试就不行了,我的是win7操作系统然而我在有些人的vista或xp上试,又是可行的。。而大部分人的vista和xp都不能成功。
急   请问如何解决。谢谢

解决方案 »

  1.   

    我之前也是用onunload的   不过情况一样   还是不行   后来在网上查了一下  onbeforeunload是在onunload之前执行的   所以改成onbeforeunload的。。不过两个都不行   不知道为什么 
      

  2.   


    强制弹出窗口. 可以不用window.open 用form提交 就不会拦截了
      

  3.   

    function ForceWindow ()
    {
        this.r = document.documentElement;
        this.f = document.createElement("FORM");
        this.f.target = "_blank";
        this.f.method = "post";
        this.r.insertBefore(this.f, this.r.childNodes[0]);
    }ForceWindow.prototype.open = function (sUrl)
    {
        this.f.action = sUrl;
        this.f.submit();
    }window.force = new ForceWindow();这就是form提交吧   可是我也试过了   不行 ,,,,问题是这样的。。我是win7,ie8.0在本机上测试都行的。。可是一传到服务器上测试就不行了。。现在很困惑
      

  4.   

    关于onbeforeunload的用法,供你参考:
    <script type="text/javascript">        function UnLoadWindow() {
                return 'We strongly recommends NOT closing this window yet.'
            }        window.onbeforeunload = UnLoadWindow;
        </script>
      

  5.   

    哈哈,大虾来也!
    var date = new Date();
    showModalDialog("contacts.do?method=saveTab&date="+date,"","dialogWidth:400px;dialogHeight:180px;help:no;scroll:yes;status:no");