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(fN ame).docum ent.body.s crollHeigh t;
//var h= window.frames[fName].frame Element.st yle.height ;
//var h= window.frames[fName].docum ent.body.s crollHeigh t;
//var h= window.frames[fName].docum ent.body.o ffsetHeigh t ;
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
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(fN
//var h= window.frames[fName].frame
//var h= window.frames[fName].docum
//var h= window.frames[fName].docum
alert(h);
}
I tried all possible expressions like document.body.scrollHeight
Thanks
A
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.