我在 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 页面错误:
Error: Unspecified error.
有什么想法吗?
最佳答案
检查您的 (itemChanged) 值。是否有可能是其他原因导致错误?它对我来说很好。
Jsbin样本。
关于javascript - 为什么我的 onbeforeunload 处理程序导致 "Unspecified error"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1010681/