Is there an event when that triggers when the window is closing.... I am
talking about when the user clicks on the cross on the right top corner of
the window!!! 10 9805
"Tom Szabo" <to*@intersoft. net.au> escreveu na mensagem
news:41******@d news.tpgi.com.a u...
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!! The Onunload body element an example is given above: <body OnunLoad="Javas cript:window.al ert('Thanks for visiting our site')">
"Oscar Monteiro" <of**@hotmail.c om> wrote in message news:<41******* *************** *@news.telepac. pt>... "Tom Szabo" <to*@intersoft. net.au> escreveu na mensagem news:41******@d news.tpgi.com.a u...
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!! The Onunload body element an example is given above: <body OnunLoad="Javas cript:window.al ert('Thanks for visiting our site')">
No such thing as an 'Onunload body element' - onunload is an event
handler property (of window). The name of the event you're interested
in is unload, which invokes the [window.]onunload handler.
MSIE/FireFox 0.9+ also support window.onbefore unload, which allows
more leeway in running script, including cancelling the close
entirely.
Most people who ask about this are interested in discriminating
between an actual attempt to close the window (or navigate to another
site) and a simple change of page within their own site. Since the two
event handlers are called by any of these - the unloading of the
current document is the trigger - all sorts of tortuous methods have
been configured to catch an actual close event, from popping up 'spy'
windows to observe the action, to flagging internal links to trap
their usage to...you name it. My experience with most of these has not
been encouraging. Here's a novel approach from glenngv of
codingforums.co m:
<html>
<head>
<title>Detectin g Closing of Window in IE</title>
<script language="javas cript">
function doUnload()
{
if ((window.event. clientX < 0) && (window.event.c lientY < 0))
{
alert("The window is closed...");
}
}
</script>
</head>
<body onunload="doUnl oad()">
<h3>Detecting Closing of Window in IE</h3>
Do the 3 ways below and see the difference:<br>
1. Try to refresh the page.<br>
2. Try to type any URL in the address bar.<br>
3. Try to close this window by clicking X button of this window.
</body>
</html>
Catches the mouseclick position. IE only, but easily modifiable. What
exactly did you need to do?
RobB" <fe******@hotma il.com> wrote in message
news:ab******** *************** ***@posting.goo gle.com... "Oscar Monteiro" <of**@hotmail.c om> wrote in message
news:<41******* *************** *@news.telepac. pt>... "Tom Szabo" <to*@intersoft. net.au> escreveu na mensagem news:41******@d news.tpgi.com.a u...
Is there an event when that triggers when the window is closing.... I
am talking about when the user clicks on the cross on the right top
corner of the window!!! The Onunload body element an example is given above: <body OnunLoad="Javas cript:window.al ert('Thanks for visiting our
site')"> No such thing as an 'Onunload body element' - onunload is an event handler property (of window). The name of the event you're interested in is unload, which invokes the [window.]onunload handler. MSIE/FireFox 0.9+ also support window.onbefore unload, which allows more leeway in running script, including cancelling the close entirely.
Most people who ask about this are interested in discriminating between an actual attempt to close the window (or navigate to another site) and a simple change of page within their own site. Since the two event handlers are called by any of these - the unloading of the current document is the trigger - all sorts of tortuous methods have been configured to catch an actual close event, from popping up 'spy' windows to observe the action, to flagging internal links to trap their usage to...you name it. My experience with most of these has not been encouraging. Here's a novel approach from glenngv of codingforums.co m:
<html> <head> <title>Detectin g Closing of Window in IE</title> <script language="javas cript"> function doUnload() { if ((window.event. clientX < 0) && (window.event.c lientY < 0)) { alert("The window is closed..."); } } </script> </head> <body onunload="doUnl oad()"> <h3>Detecting Closing of Window in IE</h3> Do the 3 ways below and see the difference:<br> 1. Try to refresh the page.<br> 2. Try to type any URL in the address bar.<br> 3. Try to close this window by clicking X button of this window. </body> </html>
Hi Rob,
What I want to do is:
firstly if the child window is closed by the user using the "x" on the top
left corner (that is prematurely considering the actual application) I need
to enable the data controls on the parent window (opener)!!
secondly, if the parent window is closed in the same way, I need to close
the child. -> this is needed because from the child I can disable all the
controls on the parent, but not the "X", so they can close the window...
Thanks for the stuff by the way, I will try soon,
Regards,
Tom Catches the mouseclick position. IE only, but easily modifiable. What exactly did you need to do?
Hi Rob,
I have tried, and it doesn't do anything!
No error with the script, just nothing.
Any clues?
TIA,
Tom
"RobB" <fe******@hotma il.com> wrote in message
news:ab******** *************** ***@posting.goo gle.com... "Oscar Monteiro" <of**@hotmail.c om> wrote in message
news:<41******* *************** *@news.telepac. pt>... "Tom Szabo" <to*@intersoft. net.au> escreveu na mensagem news:41******@d news.tpgi.com.a u...
Is there an event when that triggers when the window is closing.... I
am talking about when the user clicks on the cross on the right top
corner of the window!!! The Onunload body element an example is given above: <body OnunLoad="Javas cript:window.al ert('Thanks for visiting our
site')"> No such thing as an 'Onunload body element' - onunload is an event handler property (of window). The name of the event you're interested in is unload, which invokes the [window.]onunload handler. MSIE/FireFox 0.9+ also support window.onbefore unload, which allows more leeway in running script, including cancelling the close entirely.
Most people who ask about this are interested in discriminating between an actual attempt to close the window (or navigate to another site) and a simple change of page within their own site. Since the two event handlers are called by any of these - the unloading of the current document is the trigger - all sorts of tortuous methods have been configured to catch an actual close event, from popping up 'spy' windows to observe the action, to flagging internal links to trap their usage to...you name it. My experience with most of these has not been encouraging. Here's a novel approach from glenngv of codingforums.co m:
<html> <head> <title>Detectin g Closing of Window in IE</title> <script language="javas cript"> function doUnload() { if ((window.event. clientX < 0) && (window.event.c lientY < 0)) { alert("The window is closed..."); } } </script> </head> <body onunload="doUnl oad()"> <h3>Detecting Closing of Window in IE</h3> Do the 3 ways below and see the difference:<br> 1. Try to refresh the page.<br> 2. Try to type any URL in the address bar.<br> 3. Try to close this window by clicking X button of this window. </body> </html>
Catches the mouseclick position. IE only, but easily modifiable. What exactly did you need to do?
RobB wrote: function doUnload() { if ((window.event. clientX < 0) && (window.event.c lientY < 0)) { alert("The window is closed..."); } }
The alert would also be shown, if a user types in another address and
hits enter (or navigates with keys) while his mouse is above and left
from the browser window.
This might be corrected by adding the screenX and screenY values. If the
resulting value is still negative, the window might be closed. But I
don't know if this must be the case as I couldn't find a reference who
describes the possible values of clientX/clientY for a closed window.
function doUnload() {
var e = window.event;
if (e.clientX+scre en.width < 0 && e.clientY+scree n.height < 0) {
alert("The window is closed...");
}
}
Daniel
Daniel Kirsch <Iw************ *****@gmx.de> wrote in message news:<cn******* ******@news.t-online.com>... RobB wrote: function doUnload() { if ((window.event. clientX < 0) && (window.event.c lientY < 0)) { alert("The window is closed..."); } } The alert would also be shown, if a user types in another address and hits enter (or navigates with keys) while his mouse is above and left from the browser window.
This might be corrected by adding the screenX and screenY values. If the resulting value is still negative, the window might be closed. But I don't know if this must be the case as I couldn't find a reference who describes the possible values of clientX/clientY for a closed window.
function doUnload() { var e = window.event; if (e.clientX+scre en.width < 0 && e.clientY+scree n.height < 0) { alert("The window is closed..."); } }
Daniel
Daniel Kirsch wrote:
The alert would also be shown, if a user types in another address and hits enter (or navigates with keys) while his mouse is above and left from the browser window.
Interesting - that wasn't my experience: Event.clientX remained
positive except while clicking the 'x', then going wildly negative.
Not to worry: couldn't get this to work in Firefox; both Event.clientY
and Event.pageY remained set to zero regardless. Presumably IE's event
handling in this regard is non-standard (or buggy). Couldn't come up
with a viable solution.
> > > function doUnload() { if ((window.event. clientX < 0) && (window.event.c lientY < 0)) { alert("The window is closed..."); } }
function doUnload() { var e = window.event; if (e.clientX+scre en.width < 0 && e.clientY+scree n.height < 0) { alert("The window is closed..."); } }
I don't get this! Does anyone's MSIE pops up anything when they click "x" in
the top left corner???
I can't seem to achieve anything like that!
What is wrong?
TIA
Tom
This comes from Tek-Tips: http://www.tek-tips.com/viewthread.cfm?qid=924821
By adam0101:
In the onunload event of every page, open the survey at a position off
the screen. In the onload event of every page, close the survey. Then
put a timer in the survey window that repositions itself into view after
about 5 seconds. If another page from your site doesn't get loaded
within 5 seconds to close the survey, it'll display itself.
The tricky part is referencing the popup from the new page. This should
work:
CODE
<body onload="window. open('javascrip t:window.close( )','popupSurvey ')"
onunload="windo w.open('survey. html','popupSur vey','left=-5000')">
In the survey:
CODE
<script>
setTimeout('mov eTo(0,0)',5000) ;
</script>
Adam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
On 26 Nov 2004 09:55:01 GMT, Theo Developer <th**@involveit .nl> wrote:
[snip] <body onload="window. open('javascrip t:window.close( )','popupSurvey ')" onunload="windo w.open('survey. html','popupSur vey','left=-5000')">
Which will be blocked by every pop-up blocker in existence.
setTimeout('mov eTo(0,0)',5000) ;
Decent browsers can also ignore that.
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christopher W. Douglas |
last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a
method that handles several events, such as closing a form and changing the
visible status of a form. I have some code that applies to all these
events, but I need to have specific code execute when the form closes. The
properties for this method are sender (the originator) and e (event
arguments). I know how to get typeof (sender) to determine what form or...
|
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 buttons: Accept and Cancel.
When press the Accept button, the browser is closing, and when press the
Cancel button, the browser isn´t closing.
I have tried with the event onunload, but this closes first the browser, and
|
by: Chris Bruce |
last post by:
In my application I need a way to distiguish between the following events:
1. When a user closes an MDI child window.
2. When the user closes the MDI parent window which subsequently closes
the MDI child window.
My application does certain logic when the user actually closes the MDI
child form by clicking the "X" in the upper right hand. My application,
however, should not execute this logic if the user closes the MDI parent. I...
|
by: Chirag Malvi |
last post by:
hello all,
I am developing the web application using ASP.net and VS.2003 IDE.
here is the situation which i want to implement.
1) User is browsing some webform. I want to trap this event. this i am doing
with Session_Onstart.
2) Now when user is exiting i.e. closing the browser window i want to trap
this event and perform some operation. I tried using Session_OnEnd event,but
|
by: Stan Sainte-Rose |
last post by:
Hi,
Which event is called when the user click on the close window icon (X) ?
I want, when he clicks on this icon, to display a message before closing the
form.
If he replys by No, I don't want to close the form.
Thks for your help
Stan
| |
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 signal to server.
This seems to be achievable with body unload events, but it is little
too much, as even if user navigate within my site, this event will be
generated, this can be avoided by handling onclick of each link, so
that I'll know exactly...
|
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", I'll need to kill the session.
Now, with the onbeforeunload event, I can handle this quite easily in IE, but in FireFox, it's another matter. For one thing, FireFox seems to empty out its event object on a page unload, so it's very hard to track...
|
by: karthik juneni |
last post by:
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()
|
by: jimmy |
last post by:
Hi all,
I want to capture the event when the browser's close button is
clicked
in an html page.
I tried using the event.ClientX and event.ClientY property in the
body unload event, and this helps to recognise whether the close
button is clicked( also differentiates whethet refresh was clicked).
The problem arises whenever i try to close the window by resizing it
or by right clicking at the bottom of the page and then closing it.
Can...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |