Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Auto-resize a same-domain iframe to the height of it's content
(function($) {
$.fn.extend({
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)
resize(obj);
} else {
obj.load(function() {
resize(obj);
})
}
});
function resize(obj) {
obj.height(obj.contents().find('body').height());
}
}
});
})(jQuery);
@Phil-B
Owner

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
Something went wrong with that request. Please try again.