Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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

Hi!
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;
}
else
{
     if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{ //IE 6+ in 'standards compliant mode'
     myHeight = document.documentElement.clientHeight;
}
else
{
     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
  #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
Default

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.

Peter


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





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