Problem with scrollHeight and clientHeight

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
busin3ss
Forum Newbie
Posts: 6
Joined: Mon Sep 25, 2006 4:58 pm

Problem with scrollHeight and clientHeight

Post 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!
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Code: Select all

document.documentElement?document.documentElement.scrollTop:document.body.scrollTop;
busin3ss
Forum Newbie
Posts: 6
Joined: Mon Sep 25, 2006 4:58 pm

Post 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?
Post Reply