472,337 Members | 1,237 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

How to capture browser closing event with Javascript

Hi all,

Iam trying to capture windows closing event (i.e) when the user clicks
on the "X" button i want to capture that event and want to update some
values in the database.I tried two methods but iam getting problems
with the two methods.

First,one i tried with

function Unload()
{
if (window.event.clientX 0 && window.event.clientY < 0)
{
//Browser closing
}
}

But this method is called even when the user ic hitting the back
button or refreshing the page.

Second thing i tried was

function Unload()
{
if (window.screenLeft screen.width)
{
//Browser closing
}
else
{
//Browser refresh
}
}

This works fine for browser refresh but this method is not called when
the user closes the browser.

Does any one know how to do this.

Any urgent help will be appreciated.

Thanks in advance.
{

Mar 30 '07 #1
1 10469

"karthik juneni" <ka***********@gmail.comwrote in message
news:11**********************@y66g2000hsf.googlegr oups.com...
Hi all,

Iam trying to capture windows closing event (i.e) when the user clicks
on the "X" button i want to capture that event and want to update some
values in the database.I tried two methods but iam getting problems
with the two methods.

First,one i tried with

function Unload()
{
if (window.event.clientX 0 && window.event.clientY < 0)
{
//Browser closing
}
}

But this method is called even when the user ic hitting the back
button or refreshing the page.

Second thing i tried was

function Unload()
{
if (window.screenLeft screen.width)
{
//Browser closing
}
else
{
//Browser refresh
}
}

This works fine for browser refresh but this method is not called when
the user closes the browser.

Does any one know how to do this.

Any urgent help will be appreciated.

Thanks in advance.
My advice is, forget it. Design the requirement out of the system. Anything
that happens outside the client area of a browser belongs to the host system
and is best left out of bounds of a web application.

Any solution will be a kludge and apt to be broken by a later update to the
browser.
Mar 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Derek | last post by:
Hello: I want to capture the event when a browser is closing, to give to the user the posibility of close or no this browser. When the browser is...
1
by: KS | last post by:
Is it possible to somehow capture that the user is closing the browser by clicking the X at the top right corner? I want to run a javascript when...
5
by: Uma Muthu | last post by:
Hello Everyone, How can I capture the event of closing the IE browser from within an ASP.NET web application? TIA, Uma
4
by: Bill Manring | last post by:
I need to capture the event when the user closes the browser in my application. I have some code in the session_End event, which works fine when...
1
by: Feng | last post by:
Hi, Need help on the following issue. We need to clean up some session specific backend resource when a user ends his session. We have a...
6
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user...
7
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the...
1
by: sambati | last post by:
Hi Guys, I want to execute script function for the following conditions , 1. when user press Alt+F4 key 2. from...
4
by: mbatestblrock | last post by:
I hope this makes some sense. My ultimate goal here is to execute a block of code if the mouse has not moved in a minute or so within the broswer. ...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.