Solved

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

Posted on 2004-10-04
6
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 25 total points
ID: 12224315
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
ID: 12224689
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
ID: 12225255
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

695 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