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
I need to get a custom alert box when user clicks on 'X' (window close).
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
Html code
<html>
<head>
<script type="text/javascript">
window.onbeforeunload = function() {
return "Did you save your stuff?"
}
</script>
</head>
<body>
</body>
</html>