Martin Honnen said:
var docHeight;
if (typeof document.height != 'undefined') {
docHeight = document.height;
}
else if (document.body && typeof document.body.scrollHeight !=
'undefined') {
docHeight = document.body.scrollHeight;
}
should work with NN4 and later and IE4 and later. Only problem is
IE6/Win in standards compliant mode where you need
document.documentElement.scrollHeight
so with some more checks
var docHeight;
if (typeof document.height != 'undefined') {
docHeight = document.height;
}
else if (document.compatMode && document.compatMode != 'BackCompat') {
docHeight = document.documentElement.scrollHeight;
}
else if (document.body && typeof document.body.scrollHeight !=
'undefined') {
docHeight = document.body.scrollHeight;
}
Thanks for your suggestions but these methods aren't returning the actual
height of the page (the 'scrollable' height)
I know can use object.scrollHeight to retrieve the scrolling height of the
object:
http://www.msdn.microsoft.com/library/default.asp?url=/nhp/default.asp?contentid=28000441
But when I use:
document.write("document.body.scrollHeight is " +
document.body.scrollHeight);
It doesn't return the correct value.
Please see\try the html at the end of this post where I try many different
methods to get the value I want.
Thanks for any suggestions off anyone,
Paul
----------
<html>
<head>
<title>Example</title>
<SCRIPT TYPE="text/javascript">
<!--
function redo()
{
window.location.reload();
}
window.onresize = redo;
//-->
</SCRIPT>
<body>
<SCRIPT TYPE="text/javascript">
<!--
document.write("document.body.scrollHeight is " +
document.body.scrollHeight);
document.write("<br>document.body.clientHeight is " +
document.body.clientHeight);
document.write("<br>document.body.offsetHeight is " +
document.body.offsetHeight);
document.write("<br>document.body.clientHeight is " +
document.body.clientHeight);
document.write("<br>document.body.scrollHeight is " +
document.body.scrollHeight);
document.write("<br>document.documentElement.scrollHeight is " +
document.documentElement.scrollHeight);
document.write("<br>document.height is " + document.height);
document.write("<br>window.dialogHeight is " + window.dialogHeight);
document.write("<br>screen.height is " + screen.height);
document.write("<br>document.scrollHeight is " + document.scrollHeight);
var docHeight1;
if (typeof document.height != 'undefined') {
docHeight1 = document.height;
}
else if (document.body && typeof document.body.scrollHeight !=
'undefined') {
docHeight1 = document.body.scrollHeight;
}
document.write("<br><br>docHeight1 is " + docHeight1);
var docHeight2;
if (typeof document.height != 'undefined') {
docHeight2 = document.height;
}
else if (document.compatMode && document.compatMode != 'BackCompat') {
docHeight2 = document.documentElement.scrollHeight;
}
else if (document.body && typeof document.body.scrollHeight !=
'undefined') {
docHeight2 = document.body.scrollHeight;
}
document.write("<br>docHeight2 is " + docHeight2);
//-->
</SCRIPT>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
<p>Text to make the page longer in vertical height. Need to work out exactly
how long this is.</p>
</body>
</html>