#1
  1. No Profile Picture
    JRM
    Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Jul 2003
    Posts
    108
    Rep Power
    16

    JavaScript refresh/back detection


    Is there a way to detect, through JavaScript, if a user has done a refresh? And if someone went to a page and back with the back button? (with the back button instance I probably could check to see if there is something in the "forward" part of the history object)

    Example 1:

    User is on page1.htm and presses refresh.

    example 2:

    User is on page1.htm clicks a link to go to page2.htm, then they click the back button (this scenario I want to know if they clicked the back button to get to page1).

    Thank you,

    JRM
  2. #2
  3. http://tinyurl.com/cz56g
    SEO Chat Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    D0RDRECHT NL
    Posts
    6,063
    Rep Power
    31
    Yes. Google for document.referrer and you'll get to this (www.javascript-page.com/referrer.html) for example. And there's more, try the search. Good luck.
  4. #3
  5. No Profile Picture
    JRM
    Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Jul 2003
    Posts
    108
    Rep Power
    16
    I am able to get the referrer, the problem is that when a person presses refresh or goes back to a pack by clicking on the back button, the referrer is still the origonal referrer.

    Example:
    A user comes from somedomain.com/blah.htm to my page1.htm. if they refresh the referrer is still somedomain.com/blah.htm (Same with the other example).

    Thank you,

    JRM
  6. #4
  7. http://tinyurl.com/cz56g
    SEO Chat Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    D0RDRECHT NL
    Posts
    6,063
    Rep Power
    31
    If that doesn't work in your case (which is odd, but there are probably a dozen possible reasons) you could try to add a query string to the URL on the referring page, and read its value on the referred-to page.

    So on page1 it would read <A HREF=page2.htm?comingfrompage1 ...>
    On page2 you could interpret that, using the location.search property, and detect which page it was coming from... Of course that only works on your own pages.

    I know that's not very elegant, but it's a workaround....

    P.S. : document.referrer is known to give useless results sometimes with frames, and in the odd browser or two.
  8. #5
  9. No Profile Picture
    JRM
    Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Jul 2003
    Posts
    108
    Rep Power
    16
    I can get the referer, just when a user goes forward then clicks the back button, the referer is still the same (it isn't the "next" page, as if the user hasn't been to the next page; if that made any sense). I want to know if a user clicked the back button to get to the page.

    Thank you,

    JRM

Similar Threads

  1. flash detection page and SEO results
    By digest in forum Google Optimization
    Replies: 5
    Last Post: Apr 20th, 2004, 11:18 PM
  2. Googlebot reading JavaScript files
    By jjkebab in forum Search Engine Optimization
    Replies: 15
    Last Post: Apr 18th, 2004, 04:42 PM
  3. Splash Pages, Cookies, & JavaScript.. Oh My!
    By TheFesta in forum Search Engine Optimization
    Replies: 1
    Last Post: Mar 22nd, 2004, 08:34 PM
  4. How much Javascript in page?
    By wirelesscove in forum Search Engine Optimization
    Replies: 2
    Last Post: Feb 20th, 2004, 02:25 PM
  5. JavaScript and div tags
    By cityneil in forum Google Optimization
    Replies: 0
    Last Post: Jun 24th, 2003, 03:46 AM

IMN logo majestic logo threadwatch logo seochat tools logo