Connecting Tech Pros Worldwide Forums | Help | Site Map

javascript on closing window

Daniel
Guest
 
Posts: n/a
#1: Jul 23 '05
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.





Dag Sunde
Guest
 
Posts: n/a
#2: Jul 23 '05

re: javascript on closing window


"Daniel" <dhw377@nothing.no.spam.com> wrote in message
news:06sbc.9029$9g.6106@lakeread04...[color=blue]
> 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.
>[/color]

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

Continue browsing to somewhere you send him?

--
Dag.


Michael Winter
Guest
 
Posts: n/a
#3: Jul 23 '05

re: javascript on closing window


On Sat, 3 Apr 2004 00:39:17 -0500, Daniel <dhw377@nothing.no.spam.com>
wrote:
[color=blue]
> 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.[/color]

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.
[color=blue]
> I do not want this script to run when a user clicks on a link on the
> page, only when they close the browser.[/color]

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.Winter@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Dennis
Guest
 
Posts: n/a
#4: Jul 23 '05

re: javascript on closing window


Michael Winter <M.Winter@blueyonder.co.invalid> wrote in message news:<opr5wgz8e15vklcq@news-text.blueyonder.co.uk>...[color=blue]
> On Sat, 3 Apr 2004 00:39:17 -0500, Daniel <dhw377@nothing.no.spam.com>
> wrote:
>[color=green]
> > 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.[/color]
>
> 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.
>[color=green]
> > I do not want this script to run when a user clicks on a link on the
> > page, only when they close the browser.[/color]
>
> 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[/color]

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
Closed Thread