View Full Version : Determining the document height

Feb 24th, 2007, 11:46 AM
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


<style type="text/css">
position: absolute;
top: 0px;
left: 0px;
width: 500px;
height: 2000px;
border: 1px solid black;

<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;
} // end function getParams()

<!-- onLoad="_params=getParams();" -->
<body onLoad="_params=getParams();">
<div id="container">
<form id="hi" action="#" method="post">
<input type="submit" onClick=('getParams();') value="click me" />

Feb 24th, 2007, 12:49 PM
This works in IE, not sure about firefox but give it a shot.


Feb 24th, 2007, 03:22 PM
Have a look at this: xDocSize (http://cross-browser.com/x/lib/view.php?sym=xDocSize).

Feb 25th, 2007, 07:23 PM
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....