Skip to content

Instantly share code, notes, and snippets.

@codfish
Last active September 16, 2015 20:52
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 codfish/cd05a8a851c28fcb0500 to your computer and use it in GitHub Desktop.
Save codfish/cd05a8a851c28fcb0500 to your computer and use it in GitHub Desktop.
Update the height of an iframe dynamically based on the height of the source content. Code is dependent on jQuery, and will only work when iframe is the same host/domain as the parent page, or if you have access to the content of the iframe. Reference: http://goo.gl/Rz3Ryz
// @example
// <iframe src="/form.html" id="infographic-iframe"></iframe>
document.getElementById('infographic-iframe').style.height = $('#infographic-iframe').contents().height() + 'px';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment