Close the browser window and control its failure

  • 2020-03-30 02:38:24
  • OfStack

Run the following code when the js page loads
window.onbeforeunload = function(){ 
return " Unsaved content may be lost "; 


This code does not show the value of return in firefox or Internet explorer and displays this text in the Google browser.

Failure to control

Trigger js to run as follows:
window.onbeforeunload = function(){}; 

Related articles: