function calcIframeHeight() {
  var the_height=
    document.getElementById('iframecontent').contentWindow.
      document.body.scrollHeight;
  document.getElementById('iframecontent').height=
      the_height;
}

function onloadfunction(){
  // register handler for iframe load event
  if (document.getElementById("iframecontent").attachEvent)
     document.getElementById("iframecontent").attachEvent("onload", calcIframeHeight); // ie
  else if (document.getElementById("iframecontent").addEventListener)
     document.getElementById("iframecontent").addEventListener("load", calcIframeHeight, true); // Safari, Firefox
}

if (window.addEventListener)
   window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
   window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
   window.onload=onloadfunction