我的应用程序中有一个dhtmlxwindow。当用户进行更改然后按Backspace时,我希望显示此对话框:
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 :(得分:0)
您无需调用beforeunload,当您的窗口卸载时,浏览器会自动触发该事件
您可以在窗口对象上使用addEventListener。
**
window.addEventListener('beforeunload',
function(){console.log(unloaded)});
**