Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to get the document height?

Reply
Thread Tools

How to get the document height?

 
 
Cylix
Guest
Posts: n/a
 
      08-07-2006
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.

 
Reply With Quote
 
 
 
 
maya
Guest
Posts: n/a
 
      08-07-2006
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...





 
Reply With Quote
 
 
 
 
Matt Kruse
Guest
Posts: n/a
 
      08-07-2006
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


 
Reply With Quote
 
Cylix
Guest
Posts: n/a
 
      08-08-2006
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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Get ubuntu ! Get ubuntu ! Get ubuntu ! Get ubuntu ! Getubuntu Windows 64bit 1 06-01-2009 08:54 AM
Using document.load() to get html NOT xml document icogs Javascript 0 01-31-2008 04:02 AM
Help with JDOM, turn org.jdom.Document -> org.w3c.dom.Document? Wendy S Java 1 08-04-2003 11:48 PM
Xalan document() function finding wrong document root Steve Carrow Java 0 07-28-2003 02:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57