Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to apply back to top link in get element by id function?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26316
    Jon Yablonski
    Participant

    Im a little new to java/css/html, and recently coded my first site. I set up my portfolio site ( http://www.jonyablonski.net/ ) to allow for javascript to switch content, allowing for all material to be contain upon a single page using this function:

    function switchContent(pageNum) {
    document.getElementById("content").innerHTML = aryPages[pageNum];

    My question is, how do I code a ‘back to top’ link on necessary content when all the page info is contained within the javascript info, and not the body?

    #64966
    Chris Coyier
    Keymaster

    Well ultimately the source code does HAVE a <body> and <html> element. So if you can find where those get generated and give one or the other an ID value, any link that #links to that ID value will jump to the top of the page.

    #64988
    Jon Yablonski
    Participant

    thanks chris!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.