Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable "Changes you made may not be saved." dialog box (Chrome)?

A similar question has been answered (Disable "Changes you made may not be saved" pop-up window), but somehow this still does not work for me.

I'm attempting to disable the Changes you made may not be saved. dialog box on form input changes. I know Chrome has removed the custom message capability, but I am having difficulty disabling the box altogether. I have the following javascript at the bottom of some HTML code:

  window.onbeforeunload = function() {
  };

  window.onbeforeunload = null;

Neither of the two work for me. When I type window.onbeforeunload into the inspector console, I get a null return value. Can the window.onbeforeunload = null; be called anywhere within the lifespan of the page? Perhaps I'm misplacing it somewhere?

like image 268
fibono Avatar asked Nov 20 '22 10:11

fibono


1 Answers

If you are using jQuery then below code will work for you

$(window).off('beforeunload');
like image 58
Vijay Sasvadiya Avatar answered May 07 '23 11:05

Vijay Sasvadiya