How to detect when user presses browser back buttons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeyaprakash(CK) Chittu

    #1

    How to detect when user presses browser back buttons

    Hi

    I have couple of pages that maintain some stateful information and i
    need to detect browser back button press and refetch the page in order
    to show the current values on the fields. Is there a simple mechanims
    thru JS.

    Thanks
    CK

  • HikksNotAtHome

    #2
    Re: How to detect when user presses browser back buttons

    In article <3F5FAC9A.20304 07@oracle.com>, "Jeyaprakash(CK ) Chittu"
    <CK.Jeyaprakash @oracle.com> writes:
    [color=blue]
    >Hi
    >
    >I have couple of pages that maintain some stateful information and i
    >need to detect browser back button press and refetch the page in order
    >to show the current values on the fields. Is there a simple mechanims
    >thru JS.[/color]

    No. Javascript has no way of knowing if I click on the Back button. It can only
    know that I am leaving/have left the page, but not how I left it.

    If you are trying to track data, then you need to approach it differently. Any
    JS approach will fail when its disabled/not available.

    The only way that I know of, that will ensure a reload, is to make the URL
    unique each time. The simplest way to do that is to append the current time to
    the page, and then check it when the page loads. If its over XXX milliseconds
    old, then redirect it back to itself, with the new time appended.

    --
    Randy

    Comment

    Working...