Skip to content

Instantly share code, notes, and snippets.

@cloudscape-germany
Last active December 26, 2015 00:08
Show Gist options
  • Select an option

  • Save cloudscape-germany/7061395 to your computer and use it in GitHub Desktop.

Select an option

Save cloudscape-germany/7061395 to your computer and use it in GitHub Desktop.
Dynamic iFrame
window.onload = function() {
// Instance variables
var parentDiv;
var theIframe;
var contentDoc;
var newScrollHeight;
parentDiv = parent.document.getElementById('DivID');
theIframe = parentDiv.getElementsByTagName('iframe')[0].contentWindow.document;
contentDoc = my_iFrame.documentElement;
// Get iFrame's content height, X-Browser, X-OS
my_scrollHeight = Math.max(theIframe.body.scrollHeight, theIframe.body.offsetHeight, contentDoc.clientHeight, contentDoc.scrollHeight, contentDoc.offsetHeight );
// Change height of containing Div Element and of iFrame itself
theIframe.style.height = newScrollHeight + "px";
parentDiv.style.height = newScrollHeight + "px";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment