Problem with alert on page redirect or reload

  • 1
  • Problem
  • Updated 3 years ago
  • Not a Problem
Greetings, 

I'm having a problem with one of my pages where if I navigate away from the page, or reload the page, then I get an alert message asking for confirmation of the navigation or reload. we have another page that is similar to this where we don't have that problem, nor do we have this problem in our staging or production environments. I compared the pages side by side and there's while there are some differences (JavaScript), there's nothing configuration wise that I can see that would cause problems.

That said, we did move some JavaScript into a static resource, could this be a cause?

Any insight would be helpful. Thanks!
Photo of John Freese

John Freese

  • 542 Points 500 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Generally the issue here is that somehow your page processes are creating model changes.  This could be a new row made on page load,  or some data change..  Then in your model you have the "Prevent users from leaving page..." (advanced tab) property selected. 

The trickiest situations occur with page includes.  They don't show up in your initial review of models,  but once the included page gets called,  all its models are in the page and will fire that unsaved changes warning... 

Happy sleuthing. 
Photo of Kyle Mathis

Kyle Mathis

  • 576 Points 500 badge 2x thumb
Hi Rob,

 Is there anyway to turn off 'Prevent users from leaving page' globally? Since the latest update it's really tanking us now that we have to go to every page and every model and turn it off.

Thanks
Photo of John Freese

John Freese

  • 542 Points 500 badge 2x thumb
I finally found the problem. Someone put in a window.onbeforeunload in a in a static resource that I was unaware of. Thanks for the reply.