Link to home
Start Free TrialLog in
Avatar of andy7789
andy7789

asked on

cannot get scrollHeight of dynamically loaded iFrame

Hi X-perts,

I need to adjust hight of iframe for dynamically loaded content (outside http). I have done it hundreds of times for the content loaded from the same server, but, in this case, cannot get an actual iframe body params. here is a simple code:

<iframe name="calc" id="calc" width="100%" height="480" allowtransparency="yes" scrolling="no" frameborder="0" marginwidth="0" marginheight="0"></iframe>
<div class="mgunit" id="rd1"><a href="http://www......." class="pageLink" onclick="col_open(440)" target="calc" >This div should load iframe content from </a></div>

It loads an iframe just fine and next I am trying to find its hight:

function getHeight(){
alert('test');
var fName = 'calc';
 // var fName = theIframe.name;
  var h= document.getElementById(fName).document.body.scrollHeight;
  //var h= window.frames[fName].frameElement.style.height;
  //var h= window.frames[fName].document.body.scrollHeight;
  //var h= window.frames[fName].document.body.offsetHeight ;
  alert(h);

}

I tried all possible expressions like document.body.scrollHeight, or offsetHeight (for ns6) etc, but the second alert does not return anything (no errors either). Are there any tricks related to the outside content loaded into iframe? Any workaround?

Thanks

A
ASKER CERTIFIED SOLUTION
Avatar of aidinet
aidinet

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial