I want to make inform the user by displaying a confirm message that "Are you sure you want to close?" If he chooses OK then close else not. How to do using Javascript?
<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript"> window.onbeforeunload = function(){ return 'Are you sure?' }; </script> </head> <body> <form id="form1"> This is a page to be closed </form> </body> </html>
Demo
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.