alternative history.go(-1)

Discussion in 'JavaScript' started by grobar, Feb 6, 2007.

  1. #1
    Anyone know of a way to produce Something like the "onclick=history.go(-1)" command, except it would grab a fresh version of the page from the server and not just pull the old page out of the users cache.
     
    grobar, Feb 6, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You could try using document.referrer.

    
    
    function goback()
    {
         if (document.referrer)
         {
              window.location = document.referrer;
         }
         else
         {
              history.go(-1);
         }
    }
    
    Code (javascript):
    Untested.
     
    nico_swd, Feb 8, 2007 IP
  3. rays

    rays Active Member

    Messages:
    563
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    there are some issues of using document.referrer

    Note:
    The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark). Since this property returns only a string, it does not give you DOM access to the referring page.

    Ref http://developer.mozilla.org/en/docs/DOM:document.referrer
     
    rays, Feb 12, 2007 IP