how high is a page?

I am wondering if there is a solution with JS to find out how high a page is.
How many pixels. Depending on how much content is on each dynamic site, I would
like to place other content on another row.

Advertisements

In article <>,
enlightened us with...
> Hi there,
>
> I am wondering if there is a solution with JS to find out how high a page is.
> How many pixels. Depending on how much content is on each dynamic site, I would
> like to place other content on another row.
>

Wow. All your users have the same screen resolution? Neat.

[You should really use percents, not pixels. Good coding negates the
need to do this sort of check at all.]

Advertisements

> I am wondering if there is a solution with JS to find out how high a page is.
> How many pixels. Depending on how much content is on each dynamic site, I would
> like to place other content on another row.

There is a way to do this but it is highly innacurate. If you use
padding styles anywhere within the range you are measuring, those
padding distances are ignored. As such, you can only use margins when
working needing to get a more accurate measurement of the rendered
height or width of a DOM Elem.

To get the height of an object `o` use o.offsetHeight, for the width
use o.offsetWidth. For measuring the window size, in IE use
document.body.clientHeight & document.body.clientWidth in Moz use
window.innerHeight & window.innerWidth.

I know these properties work with IE and Moz but have not tested on
anything other browsers.

Merlin wrote:
> I am wondering if there is a solution with JS to find out how high a page is.
> How many pixels. Depending on how much content is on each dynamic site, I would
> like to place other content on another row.

Try the following page with different browsers. Perhaps it will be helpful.
<URL: http://cross-browser.com/x/test/clientheight.html>

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!