2012-07-18 2 views
0

나는 onbeforeunload 기능을 사용하는 사이트가 있지만 클릭으로 인해 팝업이 작동하지 않습니다. 내가링크에서 이전에로드되지 않은 기능을 사용 중지하는 창

<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> 

답변

0

이 링크를 열기 전에 window.onbeforeunload=null 배치되는 키의 변화와 함께 작동하는 것 같군 아래의 팝업 코드의 코드를

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> 
+0

시도했지만 작동하지 않았다 –

+0

나를 위해 작동하는 버전으로 답변을 업데이트했습니다. 다시 시도 할 수 있습니까? – mogelbrod

+0

음, 작동 감사하지만 팝업 창이 같은 창에서 열리고 있습니다. –

관련 문제