Detecting if the back button was used

I need to be able to detect in IE if the back button was used.  I am currently using javascript with perl as the backend.  I need to do this because my form is javascript created and creates a mess when the back button is used.  I would optimatly like to be able to refresh the form when the back button is used.

Thanks for all your help, the anser to this question seems to have been answered before but I am hoping that there is a more updated answer.  This is also an urgent matter

Who is Participating?
HonorGodSoftware EngineerCommented:
Unfortunately, I don't think that this will work.

According to the "World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1":

Source URL =

referrer of type DOMString, readonly
               Returns the URI of the page that linked to this page. The
               value is an empty string if the user navigated to the page
               directly (not through a link, but, for example, via a

A slightly more detailed explaination can be found at
This property returns a value only when the user reaches the
current page through a link from the previous page.
Otherwise, document.referrer returns an empty string;
it also returns an empty string when the link is from a secure site.

For example, if PageA.htm includes a link to PageB.htm, and
the user clicks that link, the document.referrer on PageB.htm
returns "PageA.htm". However, if the user is on PageA.htm
and types PageB.htm into the address line or uses Open in
the File menu to get to PageB.htm, the document.referrer
returns an empty string.
  I think that the important part is the last part of the first

  In the tests that I did, I couldn't get referrer to have a value
as long as the reference was from "the same site."  I presume
that this is because the referrence was considered to be from
"a secure site."

  You might need to save the "current page" in a session cookie,
and check this value when your page is loaded.  If the "previous
page" (i.e., the value of "current page" cookie) is inappropriate,
then the form would need to be reloaded.
Hi Ralph,

Try using the referrer property.  See this:

Check if the referrer to your form page contains the url of your results page.  If it does, then you came from 'the wrong direction' and need to refresh the form.

I hope this makes sense.

Peace and joy.  mvan
ralphsautoAuthor Commented:
I am still trying to work this out so if there was a way to keep this, so that I can review it more later.  I agree HonorGod should get the points, and no one else has seen fit to make any replies.
... indeed, I was tacitly agreeing with HonorGod.  Peace and joy.  mvan
ralphsautoAuthor Commented:
I will close the question and split the points between the two people who answered the question, they did answer the question in good faith, even if the answer is one I did not want to hear.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.