473,385 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 10536

"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 closing, this show a confirm window with two...
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 that happends, if possible.
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 the session times out, but I need to end the...
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 "Logoff" button on the pages that handles that. But...
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 click close button in browser, I can send a...
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 item selected. After returning to the client...
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 taskbar->rightclick-> close the browser option. But My html...
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. The machine I am running this on is for internal...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.