472,127 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

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 50287
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.