473,396 Members | 1,774 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,396 software developers and data experts.

javascript on closing window

Is there a way to make a javascript do something when the user closes the
browser? I would like it to go another url or something.

I do not want this script to run when a user clicks on a link on the page,
only when they close the browser.
Thanks in advance.
Jul 23 '05 #1
3 2019
"Daniel" <dh****@nothing.no.spam.com> wrote in message
news:06sbc.9029$9g.6106@lakeread04...
Is there a way to make a javascript do something when the user closes the
browser? I would like it to go another url or something.


What do you think the user really *want* to do when he
close the browser?

Continue browsing to somewhere you send him?

--
Dag.
Jul 23 '05 #2
On Sat, 3 Apr 2004 00:39:17 -0500, Daniel <dh****@nothing.no.spam.com>
wrote:
Is there a way to make a javascript do something when the user closes
the browser? I would like it to go another url or something.
And how do you propose to do that in a closing browser?

Once the user is closing the browser, it's too late to do anything, so
don't try. Redesign your page with that in mind.
I do not want this script to run when a user clicks on a link on the
page, only when they close the browser.


That isn't possible. You can't determine why a page unloads, just that it
does, and even that depends on the browser in question. My browser will
only fire the onunload event when you navigate to another page. Refreshing
or closing does nothing except refresh and close; no events are fired.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #3
Michael Winter <M.******@blueyonder.co.invalid> wrote in message news:<op**************@news-text.blueyonder.co.uk>...
On Sat, 3 Apr 2004 00:39:17 -0500, Daniel <dh****@nothing.no.spam.com>
wrote:
Is there a way to make a javascript do something when the user closes
the browser? I would like it to go another url or something.


And how do you propose to do that in a closing browser?

Once the user is closing the browser, it's too late to do anything, so
don't try. Redesign your page with that in mind.
I do not want this script to run when a user clicks on a link on the
page, only when they close the browser.


That isn't possible. You can't determine why a page unloads, just that it
does, and even that depends on the browser in question. My browser will
only fire the onunload event when you navigate to another page. Refreshing
or closing does nothing except refresh and close; no events are fired.

Mike


In IE you can use the onBeforeUnload() event, which allows you to do
"stuff" like submit a form. It doesnt solve the "how do I know if he
clicked the X or did a refresh" problem. But it is useful in an IE
environment.

dennis
Jul 23 '05 #4

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

Similar topics

2
by: Rob Videtta | last post by:
Hi, Please Help! I have developed a custom JSP tag that produces Javascript to create a window and write HTML and Javascript to that window. This window displays an error message. The...
10
by: vinu | last post by:
I have a javascript file named select.js. This is a file which is use to pop up a calendar, when clicked on a calendar icon in an ASP file. have a close button in the calendar. When i click on the...
2
by: dsnyder | last post by:
This HTML has a bit of Javascript at the end that puts the initial focus on the userID field. It works great on Windows2000 running IE6, but the initial focus never goes to the userID field on...
4
by: ...D. | last post by:
OK. I am halfway decent with HTML. Now I want to try javascript for some things that HTML cannot do. I have looked over a tutorial & all. What I want to do is create a button, that when...
4
by: Colin Graham | last post by:
Hi guys, Just a quickie here that i hope someone can help me with. Basically i want stop the user from closing the popup window using the small x button in the top right hand corner. Im aware...
1
by: colinhumber | last post by:
Some people have noticed in my application that sometimes while rapidly opening and closing a javascript window, the window will be empty. Closing and reopening the window will not repopulate the...
12
by: Mark Fox | last post by:
Hello, I am attempting to do something very simple. I have a page MainPage.aspx and a popup window Popup.aspx. When users click on the linkbutton in the popup window I am looking to do some...
4
by: Daniel Walzenbach | last post by:
Hi, does anybody know the JavaScript the guys at Microsoft used in MS CRM to prevent people from closing a browser window and asking them (on the client) what they really want to do? If you...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
3
by: Jimmy | last post by:
It is also possible for popup window to call function in main window by using the opener property. Will "opener.someFunctionInMain(param1, param2)" in the popup window work? It's possible for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
agi2029
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,...

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.