My form pages have a beforeunload
event/function set on the window to warn the user to save their changes before moving on to a different page or refreshing. It works great, and looks something like this:
$(window).on("beforeunload", myCustomWindowBeforeUnloadFunction);
The problem is when running in development, every time I change a file in my IDE, Webpack Dev Server attempts to auto-reload the page. I want to turn off this beforeunload
event so I don't keep getting nagged with this alert in Chrome:
Are you sure you want to leave the page? Data you have entered may not be saved.
Is there a way I can run a custom function in the browser before Webpack Dev Server attempts to reload the page?