DEV Community

Rahul kumar
Rahul kumar

Posted on

Ask user to save the data before window close

window.onbeforeunload = function (e) {
   // return a string if you don't want to close
   // the returned string will be displayed in the browser
   return "Do not close please!";

  // return undefined to close the TAB
  return;
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)