Javascript 在Chrome中显示取消onbeforeunload模块窗口后的自定义确认窗口
我有这样的情况:Javascript 在Chrome中显示取消onbeforeunload模块窗口后的自定义确认窗口,javascript,window,dom-events,Javascript,Window,Dom Events,我有这样的情况: 表格是在撕开的窗户上打开的 存在未保存的更改 窗户正在关上 在这种情况下,我需要显示一个标准模块窗口, 如果用户单击“取消”,则应显示自定义确认窗口 但在Chrome中,确认窗口上的图标不会出现 在Firefox和IE上,图标在相同的情况下出现 “onbeforeunload”事件的代码: window.addEventListener('beforeunload', function (e) { // function where the confirm win
window.addEventListener('beforeunload', function (e) {
// function where the confirm window is formed
showConfirmWindow();
return e.returnValue = window.getResource('', 'ex.unsaved_changes');
});
图像的路径是正确的,因为此窗口不仅在此处使用,而且显示图像。它只有在铬和只有在这种情况下。我猜Chrome之所以节省资源是因为窗口关闭了——那么为什么要拉起图标呢。但也许有人知道如何为Chrome修复它
其他信息:如果为形成确认窗口的功能添加0毫秒超时,则会显示图标
window.addEventListener('beforeunload', function (e) {
// function where the confirm window is formed
setTimeout(showConfirmWindow, 0);
return e.returnValue = window.getResource('', 'ex.unsaved_changes');
});
但这是一个糟糕的决定