IE6: Stopping Navigation away from page
I am currently working on an application where I need to query the user before they navigate away from a page. For example, when users have changed data on the screen, but have not yet saved it and they try to move to another page they are shown a warning message.
To achieve this effect I am using the onbeforeunload event of the window object. I have a page with the following code:
Test Page
This is a test of the event.returnValue code. click here
In IE6, when you click the button, the message box is displayed, but if you click "Cancel", a javascript "Unspecified Error" occurs. Strangely, this error onlyoccurs when the navigation is done by changing the 'window.location.href' property. If you click the link on the page, the message box and cancel functions behave correctly.
This error only occurs in IE6 and not in IE5.5. Has anyone encountered this problem before?