• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1224
  • Last Modified:

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

0
ralphsauto
Asked:
ralphsauto
  • 2
  • 2
2 Solutions
 
mvan01Commented:
Hi Ralph,

Try using the referrer property.  See this:
http://www.irt.org/script/143.htm

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
0
 
HonorGodCommented:
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 = http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/DOM.txt

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
               bookmark).

A slightly more detailed explaination can be found at
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/referrer.asp
----------------------------------------------------------------------
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
paragraph.

  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.
0
 
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.
0
 
mvan01Commented:
... indeed, I was tacitly agreeing with HonorGod.  Peace and joy.  mvan
0
 
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.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now