-1

I need to get a custom alert box when user clicks on 'X' (window close).

  • User is given 'OK' and 'Cancel' button options
  • OK button closes the window. Cancel button cancels the close action
Anonymous
  • 11,748
  • 6
  • 35
  • 57
  • possible duplicate of [Javascript To Get An Alert When Closing The Browser Window](http://stackoverflow.com/questions/333665/javascript-to-get-an-alert-when-closing-the-browser-window) – Ross May 11 '15 at 18:24

2 Answers2

0

I think you may find your answer on this post which looks similar - javascript confirm dialog box before close browser window

You have to show what you have done so far

Community
  • 1
  • 1
TrojanMorse
  • 642
  • 1
  • 8
  • 16
0

Html code

<html>
  <head>
    <script type="text/javascript">
      window.onbeforeunload = function() {
          return "Did you save your stuff?"
      }
    </script>
  </head>
  <body>

  </body>
</html>
Ritesh Karwa
  • 2,196
  • 1
  • 13
  • 17