Automatically Scroll To A Div On The Landing Page

Discussion in 'JavaScript' started by phaze3131, May 6, 2009.

  1. #1
    Hey guys I have a question...

    I have been doing research and can't find out how I can automatically scroll to a div id on a new page that I link to. Is this even possible?

    I know I can scroll to a certain div on the same page with just #divid but what about if I am linking to say <a href="example.html">click here</a> and want them to auto scroll down to the say <Div id="cats">

    thanks guys!

    Travis
     
    phaze3131, May 6, 2009 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    You make the link <a href="example.html#cats">Scroll to cats on different page</a> The #-id locator works on any page
     
    PoPSiCLe, May 6, 2009 IP
  3. phaze3131

    phaze3131 Well-Known Member

    Messages:
    538
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    140
    #3
    oh wow thank you alot!

    works great!

    hey random, could you get indexed for something like that? Or do the bots know that anything including and after the "#" is irrelevant?
     
    phaze3131, May 6, 2009 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    The part after the # is deemed irrelevant, as it is, as you say, just a pointer to either the same page, or somewhere specifically on the other page - therefore, only the actual URL is counted by bots. At least if the one who's made the bot has any knowledge whatsoever. However, the actual URL will be counted as normal, just as if you didn't have the #-tag added to it.

    Glad you liked my solution, add +rep if you want :)
     
    PoPSiCLe, May 6, 2009 IP