Skip to content

Instantly share code, notes, and snippets.

@kevinthompson
Created March 19, 2013 20:45
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 kevinthompson/5199970 to your computer and use it in GitHub Desktop.
Save kevinthompson/5199970 to your computer and use it in GitHub Desktop.
Resize iFrame Example
document.write('<iframe src="iframe.html" id="unique-id" onload="resizeIframe();" />')
function resizeIframe() {
document.getElementById('unique-id').style.height = document.getElementById('unique-id').contentWindow.document.body.offsetHeight + 'px';
}
<!doctype html>
<html>
<head>
</head>
<body>
<div style="height:400px;">
<h2>iFramed Content</h2>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
</head>
<body>
<h1>This is iframed content:</h1>
<script src="embed.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment