Skip to content

Instantly share code, notes, and snippets.

@01-Scripts
Created August 8, 2015 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 01-Scripts/50dc5ba2131d6da6f394 to your computer and use it in GitHub Desktop.
Save 01-Scripts/50dc5ba2131d6da6f394 to your computer and use it in GitHub Desktop.
Iframe-Höhe automatisch an Inhalt anpassen
<script type="text/javascript">
var giframe;
var gURL;
function periodicResize(iframe){
giframe = iframe;
setInterval(resizeIframe, 500);
}
function resizeIframe() {
if(giframe.contentWindow.document.body != null && giframe.contentWindow.document.body.scrollHeight > 0){
if(giframe.contentWindow.document.URL != gURL)
giframe.height = "780px";
else
giframe.height = giframe.contentWindow.document.body.scrollHeight + "px";
gURL = giframe.contentWindow.document.URL;
}
}
</script>
<iframe width="100%" height="780" onload="periodicResize(this)" frameborder="0" scrolling="auto" marginheight="0" marginwidth="0" name="roomres" id="roomIFrame"></iframe>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment