2015-10-30 69 views
0

我的應用程序中有一個dhtmlxwindow。當用戶進行更改,然後按上退格,我想顯示該對話框:調用before卸載事件

https://cube3x.com/wp-content/uploads/2014/02/confirm-navigation.png

這是加載DHTMLX窗口中的代碼:

var win = dhxWins.createWindow("selectIt", 10, 10, 940, 550); 
     win.setText(some_text); 
     win.denyResize(); 
     win.denyPark(); 
     win.setModal(true); 
     win.center(); 
     win.attachURL("/sdgdsggh/SelectIt"); 
     win.attachEvent("onClose", function (win) { 
      return true; 
     }); 
//This is what I tried 
     win.attachEvent("beforeunload", function (win) { 
      debugger; 
      return true; 
     }); 

我知道我應該叫之前的卸載事件,但我該怎麼做?

+0

retrun從'beforeunload'事件(不具有跨瀏覽器真正不同的行爲卸載事件綁定)的字符串。僅供參考,Firefox無法顯示任何自定義字符串(不確定最新的FF版本) –

回答

0

你並不需要調用beforeunload,該事件被自動瀏覽器時,你的窗口會卸載

你可以在窗口對象上使用的addEventListener解僱。

**

window.addEventListener('beforeunload', 
      function(){console.log(unloaded)}); 

**