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
  • #26316
    Jon Yablonski

    Im a little new to java/css/html, and recently coded my first site. I set up my portfolio site ( ) 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?

    Chris Coyier

    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.

    Jon Yablonski

    thanks chris!

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