SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Page height

  1. #1
    SitePoint Guru okrogius's Avatar
    Join Date
    Mar 2002
    Location
    US
    Posts
    622
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Page height

    Is there a way to detect a page height/length in js?

    My main point is having the back top link appear only when needed.

    Thanks for your time.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    You can check for the window's height, but I've never heard of page height, unless you have a pixel-perfect design, in which case your page's height is probably listed in your HTML or CSS code. However, if you do find anything, please post the solution -- I'm sure we'd all be glad to hear what it is!

    --Vinnie

  3. #3
    SitePoint Enthusiast Analyser's Avatar
    Join Date
    Oct 2002
    Location
    Delft, The Netherlands
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can probably use the document.body's offsetHeight, scrollHeight or clientHeight properties, together with the document.height property.

    The problem is though, that the page height isn't known until the entire page has actually been rendered. If you're lucky, it's updated dynamically as the page is being rendered. In that case, you could stuff some javascript near the end of the page similar to:

    Code:
    if (document.height > document.body.scrollHeight) {
        document.write('<a href="#top"><img src="top.gif"></a>');
    }
    If that doesn't work (and I doubt it does), you might just have to put in a blank image by default, and replace it with a "back-to-top" image once the page has loaded, and (obviously) only if the page is higher than the client's scroll area.

    Just my $0.02
    "A poor programmer is he who blames his tools."
    http://analyser.oli.tudelft.nl/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •