Created
September 15, 2013 18:45
-
-
Save iyank4/6573334 to your computer and use it in GitHub Desktop.
Javascript Autoresize iframe.
This file contains 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
<iframe id="myID" src="THE_URL" width="100%" height="20" frameborder="0"></iframe> | |
<script> | |
function setIframe() { | |
$("#dsct").animate({height: $("#dsct").contents().height()+"px"}, 500) | |
} | |
$("#myID").load(function() { | |
setIframe(); // got false height, so we need to execute again after 1 second | |
setTimeout(function(){ setIframe() },1000); | |
// all the link in the iframe will be targeted to parent window | |
$("#myID").contents().find('head').append('<base target="_parent" />'); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment