Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Dec 2002
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    HTML page length in pixels



    Hello,

    Is it possible using Javascript to detect the length of an html page in pixels ? I need to do this as I have a javascript scroll but I need to stop the scroll when it reaches the end of the page. The only way I can think of doing it is by setting the javascript scroll end variable to the page length in pixels.

    Many thanks in advance.


    Rowan

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    IE has the document.body.scrollHeight property

    Not sure about everyone else...
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is a guess - haven't tested it but it might work:

    var docHeight = document.defaultView.getComputedStyle(body, '').getPropertyValue("height");

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Beyond Lament
    Posts
    424
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer

    I use something like this on my iFRAME:




    <BODY>

    <DIV id="w1c1">
    Blah, blah;
    Blah, blah;
    Blah, blah;
    </DIV>

    <script language="JavaScript">
    if (document.all){
    setTimeout("parent.document.all.moredivs1.innerHTML=w1c1.clientHeight+2", 1);
    }
    </script>

    </BODY>


    Then on the main page (outside the iFRAME):

    <span id="moredivs1">&amp;nbsp;&amp;nbsp;&amp;nbsp;</span>


    This posts the size of the DIV on the main page (outside the iFRAME)... so if I put everything inside the div (excluding this JavaScript), then it shows the size of the entire page... in pixels+2.



    Hope that helps!
    *this would be an IE only thing.
    Quíet Storm Designs ~ Art is not what you see, but what you make others see.
    · the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·


  •  

    Posting Permissions

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