Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

How you can Confirm if the user is going to Close your Browser Window.

Author: DevASP
Download Source Code :

This article is about how you can confirm if the user is going to close your browser window.

Steps you will do.


Start visual studio and create a new window application. Open the HTML design of your web page and before closing the head tag add the following JavaScript tag and functions.



<script type="text/javascript">            

function confirmClose() {                       

  alert("You have chosen to close this window");

    if (confirm("Are you sure?")) {             




      alert("Close cancelled."); {              





Now add the following HTML code to design your web page and call the above functions.


<body MS_POSITIONING="GridLayout">                                                                                                                                        

<form id="Form1" method="post" runat="server">                                       

<div align="center">                                                                



<input type="button" value="Click me to Close the window" onclick="confirmClose()"> 





<font face="arial, helvetica" size"-2">Dont forget to visit Devasp<br>        

<a href=""></a></font>               







Run your application. When you will close the browser window you will be confirm for that. If you click yes the window will be closed.

Article Comments
It's Very good for Biginners.

Posted on 1/18/2007 12:21:30 AM by Sharad Jadhav.

Add Article Comment:
Name :
Email Address :
Comments :
<< How you can create Drag and Drop Menu in your Web Application.

Disclaimer - Privacy
© 2002-2017