"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:3f********@olaf.komtel.net...
Paul wrote:
Hi,
I'm wondering if someone out there can help me overcome this
quandary. I need to be able to calculate the height of the current page. I
need to calculate the height of the page in pixels after all images and text
have been displayed. This is the area that the visitor can 'scroll' up and
down in.
I have already calculated the height of the useable part of the
browser using:
document.body.clientHeight
Has anybody any ideas?
Is this possible?
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;
}
--
Martin Honnen
http://JavaScript.FAQTs.com/
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/librar...entid=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.scrol lHeight 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>