...

View Full Version : HTML page length in pixels



rowantrimmer
12-12-2002, 09:21 PM
:rolleyes:

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

beetle
12-12-2002, 11:33 PM
IE has the document.body.scrollHeight (http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/scrollheight.asp) property

Not sure about everyone else...

brothercake
12-12-2002, 11:57 PM
This is a guess - haven't tested it but it might work:

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

cheesebagpipe
12-12-2002, 11:58 PM
http://www.mozilla.org/docs/dom/domref/dom_doc_ref20.html

Quiet Storm
12-13-2002, 02:10 AM
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.

:D

Hope that helps!
*this would be an IE only thing. ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum