lupld Posted June 4, 2009 Share Posted June 4, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160868-entire-page-height/ Share on other sites More sharing options...
lupld Posted June 5, 2009 Author Share Posted June 5, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160868-entire-page-height/#findComment-849728 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.