Retrieve required height of page

C

CWaldman

How can I retrieve the required height of a page to fit in my current
browser window's width such that I don't need the vertical scrollbar to
see the full contents of the page? In other words, I need the
document's height.

Furthermore, I need to figure out how to do this in IE6 w/o switching
to strict mode (so, the default IE6 mode = quirks).

Chad
 
A

agapeton

This may help...
var windowWidth;
var windowHeight;

if(window.addEventListener) {
windowWidth = window.innerWidth;
windowHeight = window.innerHeight;
}
else {
windowWidth = document.documentElement.clientWidth ||
document.body.clientWidth;
windowHeight = document.documentElement.clientHeight ||
document.body.clientHeight;
}

The top part is for web browsers and the bottom is for Intranet
Explorer.

I use that all the time for my JavaScript window apps...
 
D

Danny

I'd be document.body.scrollHeight on geckos/IE, although you may want
to also take a look at overflow controlling by means of 'overflow'
property in CSS.


Danny
 
C

CWaldman

That unfortunately gives me the window width/height unless we doctype
to strict mode. I want to know the document width/height.

Chad
 
C

CWaldman

That was exactly what I was looking for. Thank you.

One question: What did you mean by taking a look at the overflow
property? What should I be looking for?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top