Last active
December 26, 2015 00:08
-
-
Save cloudscape-germany/7061395 to your computer and use it in GitHub Desktop.
Dynamic iFrame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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