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 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Southwest Florida
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Determining the document height

    Hi. I've been running around the web, including a search here, but haven't hit upon a solution that works. I'm trying to determine the document height of a web page. The following code produces a 0 (zero) onload, and again when the button is pressed. Right now, I'm working with Firefox 2 on Ubuntu Edgy. I'll worry about IE compatability later. Thanks

    Code:
    <html>
    <head>
    <title>test</title>
    
    <style type="text/css">
    #container
    {
    	position: absolute;
    	top: 0px;
    	left: 0px;
    	width: 500px;
    	height: 2000px;
    	border: 1px solid black;
    }
    </style>
    
    <script type="text/javascript">
    
    var _params=new Array();
    
    function getParams()
    {
    	var _docHeight = (typeof document.height != "undefined") ? document.height : document.body.scrollHeight;
    	var _docWidth = (document.width != "undefined") ? document.width : document.body.offsetWidth;
    	alert(_docHeight);
    } // end function getParams()
    
    </script>
    </head>
    <!-- onLoad="_params=getParams();" -->
    <body onLoad="_params=getParams();">
    <div id="container">
    	<form id="hi" action="#" method="post">
    	<input type="submit" onClick=('getParams();') value="click me" />
    	</form>
    </div>
    </body>
    </html>
    Still eating dogs for Unicef....

  • #2
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    This works in IE, not sure about firefox but give it a shot.
    Code:
    document.body.clientHeight

  • #3
    Regular Coder
    Join Date
    May 2004
    Location
    Alabama, USA
    Posts
    237
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have a look at this: xDocSize.

  • #4
    New Coder
    Join Date
    Jul 2002
    Location
    Southwest Florida
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks for the help

    Thanks for the input from both of you. xDocSize() led me to the correct property (document.body.scrollHeight). Now if I could find a good cheat sheet for this stuff....
    Still eating dogs for Unicef....


  •  

    Posting Permissions

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