how know the size of a div,table and window?

Discussion in 'JavaScript' started by srdva59, Jul 22, 2009.

  1. #1
    hi,
    i looking for function to
    know the size of a div,table and window/content

    then i want move one picture to the bottom of the table/div

    i already try use the align: bottom etc and that work when i load the page
    for the first time.
    but when i change the content without reloading the page the image simply
    don´t go to the bottom, so i looking fo a way using javascript to force
    the image position to the bottom-
    thanks for your help
    :)
     
    srdva59, Jul 22, 2009 IP
  2. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #2
    For knowing the size of a div or table,

    document.getElementById('mydiv').offsetWidth;
    document.getElementById('mydiv').offsetHeight;
    Code (markup):
    For knowing the size of the window,

    function returnWindowSize() 
    	{
    		var  myHeight = 0;
                    var  myWidth = 0;
    		if( typeof( window.innerWidth ) == 'number' ) 
    		{
    		  //Non-IE
    		  myHeight = window.innerHeight;
                      myWidth = window.innerWidth;
    		} 
    		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
    		{
    		  //IE 6+ in 'standards compliant mode'
    		  myHeight = document.documentElement.clientHeight;
                      myWidth = document.documentElement.clientWidth; 
    		}   
    		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
    		{
    		  //IE 4 compatible
    		  myHeight = document.body.clientHeight;
                      myWidth = document.body.clientWidth;
    		}
    		
    		return myHeight +":"+ myWidth;
            }
    Code (markup):
    Hope this helps.
     
    Unni krishnan, Jul 22, 2009 IP
  3. srdva59

    srdva59 Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks a lot for your help
    i will try that :)
     
    srdva59, Jul 23, 2009 IP