0

我有一个使用窗口 onbeforeunload 功能的网站,但点击弹出窗口因此而无法正常工作。我如何集成代码

window.onbeforeunload="null";

在下面的弹出代码中

 <script type='text/javascript'>

    function ouvre(fichier) {
          ff=window.open(fichier,"popup","width=600px,height=300px,left=50%,top=50%")     //this._try = 1;            setTimeout('this._try = 1;', 4000);   }   function playMovie(_try) {      if (this._try == 1) { playlavideo(); }      else { alert('You must share the video to play.'); }        }


     </script>

<a href="#" onClick="ouvre('http://www.facebook.com/sharer.php?u=http://google.com/');return false"><img src="http://i.imgur.com/GnqwI.jpg" width="500" height="145" border="0"></a>
4

1 回答 1

0

这似乎有效,window.onbeforeunload=null在打开链接之前进行了关键更改。

<script type='text/javascript'>
  // Set a beforeunload callback
  window.onbeforeunload = function() { return false; };

  function open_popup(url) {
    window.open(url,"popup","width=600px,height=300px,left=50%,top=50%");
    return false;
  }
</script>
<a href="http://www.facebook.com/sharer.php?u=http://google.com/" onClick="window.onbeforeunload=null;return open_popup(this.href);"><img src="http://i.imgur.com/GnqwI.jpg" width="500" height="145" border="0"></a>
于 2012-07-18T17:41:15.760 回答