Closed Thread
Results 1 to 4 of 4

Thread: Check the history length with Javascript

  1. #1
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    Check the history length with Javascript

    I'm currently upgrading my sub domains 404 error page and have added a link which take you back to the previous page which look like this:

    HTML Code:
    <a href="javascript: history.go(-1)">Go back to previous page</a>
    Now my question is, Is it possible to check if the history length is 0? Which means the user can't go back (since there's no page to go back to) and therefor I want to remove this link in those cases.

    If it's not possible in JavaScript is it possible to solve in another way?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jacki's Avatar
    Jacki is offline Learning Programmer
    Join Date
    Sep 2009
    Location
    Switzerland
    Posts
    80
    Rep Power
    9

    Re: Check the history length with Javascript

    I think you can try with js:
    Code:
    if (document.referrer != '')
    // Go back
    I'm not good in javascript, you can also use php:
    Code:
    if(!$_SERVER['HTTP_REFERER'])
    // Go back 
    Bye!



  4. #3
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    Re: Check the history length with Javascript

    Oh, now I realize that this is actually another version of the same problem I had before with getting the last page. Thanks for the help.

  5. #4
    Jacki's Avatar
    Jacki is offline Learning Programmer
    Join Date
    Sep 2009
    Location
    Switzerland
    Posts
    80
    Rep Power
    9

    Re: Check the history length with Javascript

    You're welcome!



Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. code check: javascript to call pages...
    By Injury in forum Website Design
    Replies: 9
    Last Post: 01-07-2011, 08:08 AM
  2. Little bit of history
    By Jaan in forum The Lounge
    Replies: 2
    Last Post: 06-05-2010, 04:42 PM
  3. Your phone history
    By Jaan in forum The Lounge
    Replies: 9
    Last Post: 04-06-2009, 04:49 AM
  4. The history and basic's of C
    By nicckk in forum C Tutorials
    Replies: 8
    Last Post: 12-25-2008, 09:57 AM
  5. This Day in History
    By techni68 in forum The Lounge
    Replies: 0
    Last Post: 01-12-2007, 10:49 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts