Created
October 2, 2013 13:06
-
-
Save datchley/6793419 to your computer and use it in GitHub Desktop.
An attempt to set each iframe's width/height on the page to the width/height of it's contained document.
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
| $('document').ready(function() { | |
| $('iframe').load(function() { | |
| 'use strict'; | |
| var self = this; | |
| setTimeout(function() { | |
| var iframe = self, | |
| w = $(iframe).width(), h = $(iframe).height(), | |
| docw = iframe.contentWindow.document.width, | |
| doch = iframe.contentWindow.document.height; | |
| console.log("resizing " + w + "x" + h + " to " + docw + "x" + doch); | |
| (docw > w) && $(iframe).width(docw); | |
| (doch > h) && $(iframe).height(doch); | |
| }, 50); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment