Last active
December 24, 2015 16:39
-
-
Save ziadoz/6829640 to your computer and use it in GitHub Desktop.
Auto Resize iFrame (Same Origin)
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>iFrame</title> | |
</head> | |
<body> | |
<!-- Page Content --> | |
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> | |
<script> | |
// Resize Parent Window's Corresponding iFrame. | |
$(window).on('resize', function() { | |
if (window.self != window.top) { | |
$(parent.document).find('iframe').each(function() { | |
if (this.contentWindow.document == window.document) { | |
$(this).css({ height: $('body').height() + 'px', width: '100%' }); | |
} | |
}); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>iFrame</title> | |
</head> | |
<body> | |
<iframe src="iframe.html" frameborder="0" scrolling="no"></iframe> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment