window.onbeforeunload and window.location.href in IE
Posted
by Zuber
on Stack Overflow
See other posts from Stack Overflow
or by Zuber
Published on 2010-03-23T12:41:31Z
Indexed on
2010/05/15
8:14 UTC
Read the original article
Hit count: 369
html
|window.location
We are using window.location.href to navigate the user to a page. Also, we have configured the window.onbeforeunload event to alert users in case there are any unsaved changes.
window.onbeforeunload = confirmBeforeClose;
function confirmBeforeClose() {
if (jwd.global.inEditMode)
return "Your changes will not be saved :) and you will be punished to death";
}
In places where there are unsaved changes, and I try to use window.location.href
to navigate the user, I get the alert message.
It works fine if I click OK on the popup. However, if I click CANCEL, the JS throws an unspecified error at window.location.href.
Any help is appreciated.
© Stack Overflow or respective owner