Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to resize the iframe according to the client page width.i am using the following script for this but is it giving me 0 height any idea how can the client width can be get.
parent.document.getElementById('iframename').height =
parent.document.getElementById('iframename').contentWindow.document.body.scrollHeight

thanks
Posted
Updated 4-Nov-19 12:23pm
v2
Comments
Christian Graus 6-Jul-11 0:21am    
Are you asking/looking for width, or height ?

You can get client height in JavaScript by

//Width
document.body.clientWidth

//Height
document.body.clientHeight
 
Share this answer
 
hi,
try this code below
C#
var  myHeight  = (typeof(window.innerHeight)!='undefined'?window.innerHeight:document.body.offsetHeight);

or
C#
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 reference taken from here[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900