473,327 Members | 2,069 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,327 software developers and data experts.

Detect web window closing (X)

is there a simple way to detect a web window closing when the user hit the X
of the browser ? I want to display a message to the user when he goes out of
my web page.
I try to detect it by using the event window.unbeforeunload but this event
is fire when the page is postback...
Jul 14 '06 #1
2 1619
That event is the only way. You have to keep track in your page whether or
not the user just did something that would cause a postback and only show
the message if the user did not just do something to interact with your
page.

"sylvain" <sy*****@discussions.microsoft.comwrote in message
news:93**********************************@microsof t.com...
is there a simple way to detect a web window closing when the user hit the
X
of the browser ? I want to display a message to the user when he goes out
of
my web page.
I try to detect it by using the event window.unbeforeunload but this event
is fire when the page is postback...


Jul 14 '06 #2
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
// <!CDATA[

function window_onunload() {
alert("Window Closing");

return;
}

// ]]>
</script>
</head>
<body onunload="return window_onunload()">

--
Harolds
"sylvain" wrote:
is there a simple way to detect a web window closing when the user hit the X
of the browser ? I want to display a message to the user when he goes out of
my web page.
I try to detect it by using the event window.unbeforeunload but this event
is fire when the page is postback...

Jul 14 '06 #3

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

Similar topics

10
by: Noozer | last post by:
Is it possible to detect where on a page the click occurred when the OnClick event of the BODY tag is fired? Thx
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
2
by: NWx | last post by:
Hi, I have the following question: I have an app that uses user login/logout to identify users When user logon, I register logon time in a session variable When user logoff using the logout...
3
by: someone | last post by:
Hi, Is it possible to detect if the user has shut down the window holding my ASP2.0 page and/or if the user goes to another page? For my application I need the user to click on the EXIT button...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
8
by: Luke Matuszewski | last post by:
I have read all posts about how to detect that url have changed to new page and trigger the event handler then eg. function aidLogout(evt) { if(evt) { /* maybe via analyse of evt object i can...
7
by: tarun.kataria | last post by:
Hi All, Is there any way to detect that the user is trying to Xout the browser window instead of hitting a button. Because in my application I want to make it sure that they dont do it either...
1
by: nebulus | last post by:
I'm working on a web app that under normal circumstances will be happy with the Session_OnEnd event, but when a user leaves a page by closing the browser by either Alt+F4 or just hitting the "X",...
0
by: john ciriello | last post by:
Hi, I am trying to detect when the help window that pops up for a control can be detected when it is closing. Right now when you click anywhere the window closes but there does not seem to be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.