Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Auto-resize a same-domain iframe to the height of it's content
(function($) {
iFrameAutoHeight: function() {
return this.each(function() {
var obj = $(this);
obj.height(0); //avoid flash at full height
if (obj.contents().find('body').height() > 0) { // already loaded - from cache (ie only)
} else {
obj.load(function() {
function resize(obj) {

Phil-B commented Jun 7, 2011

This presumes that the iframe content is static, so the resize event isn't used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment