tonyf
tonyf

Reputation: 35567

Why is my onbeforeunload handler causing an "Unspecified error" error?

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?

Upvotes: 2

Views: 2914

Answers (1)

Ian Elliott
Ian Elliott

Reputation: 7686

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

Jsbin sample.

Upvotes: 2

Related Questions