identifying between refresh and close browser actions

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

    #1

    identifying between refresh and close browser actions

    When we refresh the page (F5, or icon in browser), it will first
    trigger ONUNLOAD event and then trigger
    ONLOAD event. When we close the browser (X on right top icon), it will
    trigger ONUNLOAD event.

    Now when ONUNLOAD event is triggered, there is no way to distinguish
    between
    refresh the page or close the browser.

    Here's the code fragment. The logic in window_unload() only applies to
    closing the browser, not refreshing the page.

    <BODY ONUNLOAD="windo w_unload()">
    function window_unload()
    {//logic that only applies to close the browser, not refresh the page.
    }

    Anyone knows the workaround to the problem?

    Please advise. Thanks!!
  • kaeli

    #2
    Re: identifying between refresh and close browser actions

    In article <ba8a039e.04072 21924.7551503d@ posting.google. com>,
    jrefactors@hotm ail.com enlightened us with...[color=blue]
    >
    > Now when ONUNLOAD event is triggered, there is no way to distinguish
    > between
    > refresh the page or close the browser.
    >[/color]

    If you need to care, your code is unsuitable for internet use. This group
    assumes your code is for the internet unless otherwise specified.

    I might also trigger onunload by moving to another url by typing it, by using
    a bookmark, or by clicking a link. How would you handle those?
    I might also just close a tab, yet keep my browser open (opera, netscape,
    mozilla).

    Code your application to be robust and stable and it won't matter if the user
    refreshes or closes.

    (by the by, I have yet to see a cross-browser "solution" to this problem)

    --
    --
    ~kaeli~
    He had a photographic memory that was never developed.



    Comment

    Working...