Best way to Jump to Top of Page?

Discussion in 'HTML & Website Design' started by wd_2k6, Nov 4, 2008.

  1. #1
    Was wondering if there is a preffered way to add a jump to top of the page button?

    I could either give something a name of "top" at the beggining of my document and then use:
    <a href="#top">Jump to top</a>

    Or:

    <a href="javascript:window.scrollTo(0,0)">

    Hmm I guess non javascripters won't be able to use the 2nd method, but the first one requires maybe a sandbag element or something to be named so extra markup I guess..Also SE is more likley to ignore the JS I suppose..
     
    wd_2k6, Nov 4, 2008 IP
  2. jamesicus

    jamesicus Peon

    Messages:
    477
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why not use the home key on the keyboard?

    James
     
    jamesicus, Nov 4, 2008 IP
    wd_2k6 likes this.
  3. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That is true i don't really need a jump button it's a waste of space on second thoughts, thanks for directing me towards a correct approach!
     
    wd_2k6, Nov 4, 2008 IP
  4. mkda

    mkda Active Member

    Messages:
    139
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Many sites still use the link/button b/c many people don't know the home key acts in that way as well. So, if you can, do create one. You can make it even simpler though by just adding the # at the end of the link of the current page. You don't need to make anchor tags. It's a default thing.

    For example, if the current page is abc.htm your link would be:

     
    mkda, Nov 4, 2008 IP