javascript on closing window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel

    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.


  • Dag Sunde

    #2
    Re: javascript on closing window

    "Daniel" <dhw377@nothing .no.spam.com> wrote in message
    news:06sbc.9029 $9g.6106@lakere ad04...[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.


    Comment

    • Michael Winter

      #3
      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@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

      Comment

      • Dennis

        #4
        Re: javascript on closing window

        Michael Winter <M.Winter@bluey onder.co.invali d> wrote in message news:<opr5wgz8e 15vklcq@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

        Comment

        Working...