我在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 样本。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top