
Originally Posted by
jscheuer1
Wedgy, page height is never set (at least not the apparent page height when the page's true height is less than the height of the browser window), it always varies depending upon how high the browser viewport is. This can vary dramatically among screen resolutions/sizes and user preferences.
Vinsion, window.innerHeight is not valid in IE, the most widely used browser. With a valid doctype:
document.documentElement.clientHeight
is a good equivalent, without one:
document.body.clientHeight
each usually being zero when the other is accurate so, code like this will get you the height in most browsers and on most pages:
It is usually critical for both document.body and document.documentElement that the page be loaded before you access these objects and any measurements derived from them but, I see you are already doing this 'onload' so, good work on that front.
Sweet, thanks for the feedback. Although...it seems to still not be working quite right. In responce to your question about the height of the content, it's a static page, no php here, and it's really not that tall, I believe it's exactly 380px, so unless someone's using a crazy resolution, I think it'll be fine.
Here's my updated code inside my external js file:
Code:
function valignBody(wrap) {
var free_height = (document.body.clientHeight / 2) - 190;
document.getElementById(wrap).style.padding-top=free_height + 'px';
}
And here's my updated code inside my html:
HTML Code:
<body onload="valignBody('wrap')">
<div id="preload"><script src="preload.js" type="text/javascript"></script></div>
<div id="wrap">
And my doctype
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Sorry if I'm not giving you a lot to go on, but I don't really know what else to do. If you want to see the site itself, and the code at large, here's the url: Dieman Motorsports . Vinsion .net (of course with no spaces).
Email address removed
AIM: Mushin Vin
Once again thanks,
a bunch,
seriously.
< Vin >
Edit: Edited by WA as requested
Bookmarks