Why is my onbeforeunload handler causing an “Unspecified error” error?

核能气质少年 提交于 2019-12-12 18:38:46

问题


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.';  
  }  
};  

But when I press the Cancel button on the dialog, I am getting a JavaScript page error:

Error: Unspecified error.

Any ideas?


回答1:


Check your value of (itemChanged). Is it possible something else causes the error? It works fine for me.

Jsbin sample.



来源:https://stackoverflow.com/questions/1010681/why-is-my-onbeforeunload-handler-causing-an-unspecified-error-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!