为什么我的onbeforeunload处理程序导致“未指定的错误”错误?
-
06-07-2019 - |
题
我在IE6中使用以下JavaScript函数:
window.onbeforeunload = function() {
if (itemChanged) {
return 'You have made changes to data on this page. If you navigate away from this page without first saving your data, the changes will be lost.';
}
};
但是当我按下对话框上的“取消”按钮时,我收到一个JavaScript页面错误:
错误:未指定错误。
有什么想法吗?
解决方案
检查(itemChanged)的值。是否可能有其他原因导致错误?它对我来说很好。
Jsbin 样本。
不隶属于 StackOverflow