2017-04-23 26 views
0

我有一些簡單的JavaScript,我想在聯繫頁面上運行,它應該在頁面加載時顯示彈出窗口,並在用戶導航時顯示不同的彈出窗口。Javascript無法在Chrome卸載事件上運行?

我下面的代碼在IE上工作正常,但在Chrome上onunload部分完全不起作用。

有沒有解決這個問題的方法?

<script> 
      window.onload = function(){ 
       alert('Even if you aren\'t interested, please give our design some feedback as we would like to stay current.'); 
       return; 
      } 
      window.onunload = function(){ 
       alert('Thank you for your time and consideration'); 
       return; 
      } 
    </script> 
+0

http://stackoverflow.com/questions/7794301/window-onunload-is-not-working-properly-in-chrome-browser-can-any-one -help-me – LGSon

+1

在Chrome瀏覽器中,[window.onunload]可能無法正常工作。任何人都可以幫助我?](http://stackoverflow.com/questions/7794301/window-onunload-is-not-working-properly-in-chrome-browser-can-any-one-help-me) –

回答

0

嘗試:

window.onload = function(){ 
      alert('Even if you aren\'t interested, please give our design some feedback as we would like to stay current.'); 
      return; 
     } 
     window.beforeunload = function(){ 
      alert('Thank you for your time and consideration'); 
      return; 
     } 
+0

This在Chrome中不起作用。 – Callat