我们正在使用 window.location.href 将用户导航到页面。此外,我们还配置了 window.onbeforeunload 事件以提醒用户,以防有任何未保存的更改。
window.onbeforeunload = confirmBeforeClose;
function confirmBeforeClose() {
if (jwd.global.inEditMode)
return "Your changes will not be saved :) and you will be punished to death";
}
在有未保存更改的地方,我尝试使用它window.location.href
来导航用户,我会收到警报消息。
如果我在弹出窗口中单击“确定”,它工作正常。但是,如果我单击 CANCEL,JS 会在 window.location.href 处引发未指定的错误。
任何帮助表示赞赏。