Page 1 of 1

Problem with scrollHeight and clientHeight

Posted: Tue Feb 06, 2007 8:03 pm
by busin3ss
Hi!

I'm have a .js file with the following code:

Code: Select all

var doc = document;
omg_scroll = doc.body.scrollHeight;
omg_client = doc.body.clientHeight;
calculation = Math.round(omg_client / omg_scroll);
document.write(calculation);
And I include it in an html file <script src="javascript.js"></script>

The problem is that omg_scroll & omg_client are always equal to 0. What I'm doing wrong?

To make it more clear, how can I get the scrollHeight and the clientHeight with javascript?

Thanks in advanced!

Posted: Tue Feb 06, 2007 8:08 pm
by superdezign

Code: Select all

document.documentElement?document.documentElement.scrollTop:document.body.scrollTop;

Posted: Tue Feb 06, 2007 11:29 pm
by busin3ss
superdezign wrote:

Code: Select all

document.documentElement?document.documentElement.scrollTop:document.body.scrollTop;
Thanks a lot... I tried it but it didn't worked either....

Any other suggestion?