为什么我的onbeforeunload处理程序导致“未指定的错误"?错误? [英] Why is my onbeforeunload handler causing an "Unspecified error" error?
本文介绍了为什么我的onbeforeunload处理程序导致“未指定的错误"?错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在IE6中使用以下JavaScript函数:
I am using the following JavaScript function within IE6:
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页面错误:
But when I press the Cancel button on the dialog, I am getting a JavaScript page error:
错误:未指定的错误.
Error: Unspecified error.
有什么想法吗?
推荐答案
检查(itemChanged)的值.是否有其他原因导致错误?对我来说很好.
Check your value of (itemChanged). Is it possible something else causes the error? It works fine for me.
Jsbin 示例.
这篇关于为什么我的onbeforeunload处理程序导致“未指定的错误"?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文