Jump to content

Entire Page Height


lupld

Recommended Posts

What kind of code do I need to get the entire page height and not just the height of the visible window? I've tried a couple, but they all seem to grab the windowview and not the complete document height. I also need to set the new height to a div by id with css...

 

Here's what I'm trying right now...

javascript

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}
function resize()
{
alert(myheight + "px");
document.getElementByID(BODY).style.height = myHeight + "px;";
}

 

Body Tag

<body onload="alertSize();resize();" onresize="resize();">

 

Div Tag

<div id="BODY" class="BG1" align="center" onload="resize();" onresize="resize();">

I'm pretty good with html, css, and php, and I've taken classes for VB, but I'm still getting used to the syntax of javascript, it seems like just as I understand something, there's an exception or something or other.

Link to comment
Share on other sites

This can't be anything new, I'm sure there are tons of useful applications for this besides making the div tag the full height of the document, and not just the height of the visible window. I'm sure the code comes down to .height for this browser, .clientheight for this browser, and .innerheight for all the other browsers, and then getElementByID("BODY").style.height = var height, but none of the different codes I've tried work. I get errors like "activeresize() not defined", and not knowing much about javascript, this is like saying don't eat with your hands to a baby, you can preach it all you want, but until they learn what you're saying it's not gonna do anything.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.