Last active
June 12, 2016 15:24
-
-
Save Tusko/c9bc5415abff69ee438c1564bd071ea9 to your computer and use it in GitHub Desktop.
Deffered iframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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