Last active
December 14, 2015 07:59
-
-
Save brianherbert/5054343 to your computer and use it in GitHub Desktop.
Lock an iframe within an iframe to
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
<style> | |
body { background-color:green;text-align:center;} | |
iframe { padding:0; margin:0; overflow: hidden; border: 0px;} | |
</style> | |
<script> | |
function iframeLoaded() { | |
var iframe = document.getElementById('testframe'); | |
if(iframe) { | |
var body = iframe.contentDocument.body; | |
body.style.padding = 0; | |
body.style.margin = 0; | |
// here you can meke the height, I delete it first, then I make it again | |
iframe.height = ""; | |
iframe.height = iframe.contentWindow.document.body.scrollHeight + "px"; | |
iframe.width = ""; | |
iframe.width = iframe.contentWindow.document.body.scrollWidth + "px"; | |
} | |
} | |
</script> | |
<body> | |
<iframe id="testframe" src='originalEmbed.html' onload="iframeLoaded()" /> | |
</body> |
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
<iframe width="560" height="315" src="http://www.youtube.com/embed/CrQf6cogMuI?list=FLZd7fRw0Pi4pYmg3aV10d7Q" frameborder="0" allowfullscreen></iframe> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment