Solved

How to handle the close(X) event of a browser

Posted on 2004-10-04
6
166 Views
Last Modified: 2010-04-06
Hi,
I am developing a web application using asp.net. I want to handle the close(X) event of the browser and want to do some database updation before closing the browser. How can i do this?

regards
sudhir
0
Comment
Question by:sudhir_arao
  • 2
6 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 25 total points
Comment Utility
Hi sudhir_arao,

Use Javascript onunload in the <body> tag. Have it call __doPostBack (not sure since not too good with ASP, but heard of it)

Regards,
Zyloch
0
 
LVL 6

Assisted Solution

by:snavebelac
snavebelac earned 25 total points
Comment Utility
It is very difficulty to trap the closing of a browser as there is no specific event associated with it.  The onUnload event will trigger when a user closes the browser, refreshes, clicks the back button or goes to another page.  There is no way of knowing which has been carried out.

The only way to know when a user has stopped using your web page is via the 'Session_OnEnd' either via a logout of some sort or a timeout on the server.

I am not familiar with ASP.NET but with ASP the global.asp file holds the Session_OnEnd event which will trigger code at the server when a user logouts (associated with the session.adandon function in ASP) or when the session times out (default 20 mins).

HTH

C
0
 
LVL 36

Expert Comment

by:Zyloch
Comment Utility
Ah yes, use onclose for Mozilla, for IE, here's an implementation: http://experts-exchange.com/Web/Web_Languages/JavaScript/Q_20926025.html

Regards...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XSLT 5 36
Programatically edit Web.config 8 28
Adding a hidden div to each row in a table 6 22
Re-position the objects 7 46
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now