Sorry about the obscure title, hopefully I can explain:
I have a standard, "Are you sure you wish to leave" dialog that pops up when a user tries to leave a page:
window.onbeforeunload = function() {
return 'You have unsaved changes';
}
When this is coupled with window.location.href
and the user clicking cancel an 'Unspecified error' is thrown in internet explorer 8 or earlier. The same doesn't seem to happen with other modern browsers.
<script type="text/javascript">
$('input').click(function() {
window.location.href = 'http://www.google.com'; // error is thrown here
});
</script>
<input type="button" value="Go to google" />
Is there any way I can continue to use window.location.href and get around this bug in IE8?
It's a known IE bugs. I think you can just catch that error use try block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With