469,338 Members | 8,242 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,338 developers. It's quick & easy.

How to get the document height?

As I know, the document height is depend on browser and OS usering
using,
is there any way to get the height for that particular document height?

Thank you.

Aug 7 '06 #1
3 50186
Cylix wrote:
As I know, the document height is depend on browser and OS usering
using,
is there any way to get the height for that particular document height?

Thank you.
I think this is what you want.....

var cw = document.body.clientWidth;
var ch = document.body.clientHeight;

HTH...

Aug 7 '06 #2
maya wrote:
Cylix wrote:
>As I know, the document height is depend on browser and OS usering
using,
is there any way to get the height for that particular document
height?
I think this is what you want.....
var cw = document.body.clientWidth;
var ch = document.body.clientHeight;
That is way too simple.
From http://www.javascripttoolbox.com/lib/util/index.php you can find this
solution:

// Get the height of the entire document
// --------------------------------------------------------------------
screen.getDocumentHeight = function() {
var body = screen.getBody();
var innerHeight =
(defined(self.innerHeight)&&!isNaN(self.innerHeigh t))?self.innerHeight:0;
if (!document.compatMode || document.compatMode=="CSS1Compat") {
var topMargin = parseInt(CSS.get(body,'marginTop'),10) || 0;
var bottomMargin = parseInt(CSS.get(body,'marginBottom'), 10) || 0;
return Math.max(body.offsetHeight + topMargin + bottomMargin,
document.documentElement.clientHeight,
document.documentElement.scrollHeight, screen.zero(self.innerHeight));
}
return Math.max(body.scrollHeight, body.clientHeight,
screen.zero(self.innerHeight));
};
--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Aug 7 '06 #3
How about if it is a iframe in a table?
The case is I have already set the height of iframe and set the
scrolling bar to to,

That means the overflow content would be hidden at the iframe,
Is it possible to calculate the document height?

Aug 8 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Adam | last post: by
2 posts views Thread by Gary Mayor | last post: by
12 posts views Thread by Kepler | last post: by
8 posts views Thread by Jean Pierre Daviau | last post: by
3 posts views Thread by Jan Ebbe Jensen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.