cannot get scrollHeight of dynamically loaded iFrame

Posted on 2007-10-21
Medium Priority
Last Modified: 2010-01-31
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(){
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 ;


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?


Question by:andy7789
1 Comment

Accepted Solution

aidinet earned 2000 total points
ID: 20117584
try to make a server side page (php/asp ... etc) that reads the content of "http://www......." and load it in the iframe instead of "http://www......."

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question