1
            if(!$('fieldset.quote-step4').hasClass('show')) {
                window.onbeforeunload = function() {
                    return "Are you sure you want to leave the quote request page? This will reset the form.";
                }
            } else {
                window.onbeforeunload = undefined;
            }

I have the above in a script inside of a private function that's causing a "not implemented" error in ie8.

The specific line that causes the error is: window.onbeforeunload = undefined;

From what I've read in other questions window should be declared as a local variable to fix this issue-- but I'm not sure how.

Can anyone explain this bug to me and a possible solution?

Thank you!

HandiworkNYC.com
  • 10,914
  • 25
  • 92
  • 154

3 Answers3

5

Try this:

$(window).on('beforeunload', function() {
   if($('fieldset.quote-step4').hasClass('show')) {
        return;
   }
   return "Are you sure you want to leave the quote request page? This will reset the form.";
});

And it is not the best idea to use DOM1 Handlers when jQuery is already on your page.

FloydThreepwood
  • 1,587
  • 14
  • 24
3
window.onbeforeunload = function(){};
1

onbeforeunload is an event handler; apparently; IE8 doesn't like clearing it.

You can simply set it to a function that doesn't return anything.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964