Skip to content

Instantly share code, notes, and snippets.

@Tusko
Last active June 12, 2016 15:24
Show Gist options
  • Select an option

  • Save Tusko/c9bc5415abff69ee438c1564bd071ea9 to your computer and use it in GitHub Desktop.

Select an option

Save Tusko/c9bc5415abff69ee438c1564bd071ea9 to your computer and use it in GitHub Desktop.
Deffered iframe
function resizeIframe(iframe) {
iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
}
function iFrameLoaded( id, src ) {
var deferred = $.Deferred(),
iframe = $( "<iframe class='hiddenFrame' onload='resizeIframe(this)' width='100%' scrollin='no'></iframe>" ).attr({
"id": id,
"src": src
});
iframe.load( deferred.resolve );
iframe.appendTo( "footer" );
deferred.done(function() {
iframeLoaded();
});
return deferred.promise();
}
$.when(iFrameLoaded("kf", "http://site.com/")).then( function() {
resizeIframe( document.getElementById('kf') );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment