Results 1 to 4 of 4

Thread: How to dynamically expand the javascript height?

  1. #1
    Join Date
    Oct 2008
    Posts
    105

    How to dynamically expand the javascript height?

    Hi,

    Is it possible to know the div tag height & expand it dynamically with the help of javascript?

    The div contains an image & according to the image the div gets adjusted. I want to get the actual height of the page while loading & adjust it dynamically with the help of javascript. Is this possible? If yes can I get to see an example?

  2. #2
    Join Date
    Apr 2008
    Posts
    240

    Re: How to dynamically expand the javascript height?

    Hey give this a try:

    Code:
    var DivHeight = document.getElementById(DivID).clientHeight;
    I hope this helps.

  3. #3
    Join Date
    May 2008
    Posts
    56

    Re: How to dynamically expand the javascript height?

    Try this:

    Code:
    document.getElementById("divName").style.height = windowHeight - 100+"px";
    This is an example:

    Code:
    <html><body>
    <style type="text/css">
    #divName {
         border:solid 1px #000;
         text-align:center;
     }
    </style>
    
    <script type="text/javascript">
    
      var windowWidth=screen.availWidth/2+"px";
      var windowHeight=screen.availHeight/4*3+"px"
    
    function sniffer() {
        var el=document.getElementById("divName"); 
    if(screen.width==1280) {
                       el.style.width=windowWidth;
                       el.style.height= windowHeight;
                       el.style.margin="auto";               
     } 
    else {
    if(screen.width==1024) {
                       el.style.width=windowWidth;
                       el.style.height= windowHeight;
                       el.style.margin="auto";  
     } 
    else { 
    if(screen.width==800) {
                       el.style.width=windowWidth;
                       el.style.height= windowHeight;
                       el.style.margin="auto";  
        }   
       }
      }
     }
    onload=sniffer;
    //]]>
    </script>
    
    </head>
    <body>
    
    <div id="divName"></div>
    </body></html>

  4. #4
    Join Date
    Oct 2008
    Posts
    105

    Re: How to dynamically expand the javascript height?

    Thanks a lot for the prompt reply
    Ill definitely give it a try & let you know soon.

    Regards
    Recko

Similar Threads

  1. Dynamically Loading External JavaScript and CSS Files
    By Adrina_g in forum Software Development
    Replies: 5
    Last Post: 02-03-2010, 11:36 AM
  2. How to calculate value dynamically in JavaScript?
    By KAIRU26 in forum Software Development
    Replies: 5
    Last Post: 24-02-2010, 11:01 PM
  3. How to Add and Remove HTML elements Dynamically In Javascript?
    By Level8 in forum Software Development
    Replies: 5
    Last Post: 20-02-2010, 06:48 PM
  4. Javascript to rewrite the function dynamically
    By djbbenn in forum Software Development
    Replies: 2
    Last Post: 18-06-2009, 10:19 AM
  5. How to add forms Dynamically with JavaScript
    By Neil'o in forum Software Development
    Replies: 3
    Last Post: 12-03-2009, 01:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,430,346.37753 seconds with 17 queries