javascript – HTML Element’s Height Property not set by Internet Explorer – Education Career Blog

I’ve written a Javascript script that automatically resizes the height of an IFrame, depending on its content. This is done as soon as the content of the framed page is produced; in Firefox no problem, but in IE the script is correctly executed but no effect is seen: the method is called in a callback function. Any sugestions?
If I execute the method using a button, it works perfectly, and the frame get resized.

I havn’t the code right in front of me; the resizing method looks like this:

function resizeFrame(){
    var frame = parent.document.getElementsById(; = document.offsetHeight;

And the calling function is like this:

//init function

function callbackFunction()
    //does some HTML output

I’m using Salesforce Ajax library.


I have found that in some cases in IE properties such as offsetHeight, clientHeight and scrollHeight are not correctly set when new content has been added. I’ve had to use setTimeout in order to allow the display to be repainted before being able to get accurate values from such properties.


Hard to really debug your code without seeing it, but the following example works well for me in IE and Firefox.

<!DOCTYPE html>
  <script type="text/javascript" >

    onframeload=function(iframe) {
      var doc = iframe.contentWindow.document; = Math.max(
        doc.body.offsetHeight // IE prefers this value
      ) + "px";

  <div id="page">
    <iframe src="about:blank" onload="onframeload(this)">

Leave a Comment