Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 10th, 2003, 04:50 AM
Registered User
Join Date: Oct 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Change height of div element if < window height

I'm a comlete idiot when it comes to javascript and dom structure.
What i'm trying to do is to change a absolute positioned <div>'s height to browser window height if the div's height is lesser than the window height.

I'm currently using this function to retrive window height.
function get_windowHeight()
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' )
{ //Non-IE
     myHeight = window.innerHeight;
     if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{ //IE 6+ in 'standards compliant mode'
     myHeight = document.documentElement.clientHeight;
     if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
     { //IE 4 compatible
         myHeight = document.body.clientHeight;
return myHeight;

Anoone how can give me a pointer how to move from here?
Very cratefull for answers
/ Joel Junström
Reply With Quote
  #2 (permalink)  
Old October 10th, 2003, 09:14 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

Looks like you are good getting the screen height, now you need to set the div right?

myDiv.style.height = x;

That should do it.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
div within a div and inherting the height brettdavis4 CSS Cascading Style Sheets 1 January 23rd, 2007 09:59 AM
Fixed table height and row height rajanikrishna HTML Code Clinic 3 January 18th, 2007 12:42 AM
minimise a <div> (adjust height) crmpicco Javascript How-To 1 September 21st, 2005 01:39 AM
'Auto' height of <DIV>s anshul HTML Code Clinic 3 April 28th, 2005 09:13 AM
line-height -n- background-color with <DIV> block anshul HTML Code Clinic 11 September 5th, 2004 02:15 PM

All times are GMT -4. The time now is 11:05 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.