[thelist] Javascript for 'to top' if page is long, otherwise not

Hassan Schroeder hassan at webtuitive.com
Fri Nov 18 12:22:17 CST 2005

john at johnallsopp.co.uk wrote:

> I'd like a 'top' link at the bottom of pages which are longer than a
> screen depth...

> Can anyone help me out with this?

/* miniimally tested: FF 1.0.x/Linux, IE6/Win */

var thisHTML = document.getElementsByTagName("html")[0];
if ( thisHTML.scrollHeight > thisHTML.clientHeight )
    var backToTop = document.createElement("a");
    backToTop.appendChild(document.createTextNode("back to top"));

Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                          dream.  code.

More information about the thelist mailing list