Created
December 20, 2011 19:51
-
-
Save mrpollo/1502971 to your computer and use it in GitHub Desktop.
MooTools 1.12 and Earlier iFrame resize, mainly used for Joomla compatibility
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
| window.addEvent('domready', function(){ | |
| function resizeIframe( iframe ){ | |
| var innerDoc = $( ( iframe.contentWindow ) ? iframe.contentWindow.document.body : iframe.contentDocument.body ) ); | |
| var objToResize = (iframe.style) ? iframe.style : iframe; | |
| var sizes = innerDoc.getSize(); | |
| var offsetHeight = sizes.scrollSize.y + 50; | |
| objToResize.height = offsetHeight + 'px'; | |
| } | |
| if( $('iframe') != null ){ | |
| var iframe = $('iframe'); | |
| iframe.addEvent('load', function(){ | |
| resizeIframe( this ); | |
| }); | |
| if( window.webkit || window.opera ){ | |
| var source = iframe.src; | |
| iframe.src = ''; | |
| iframe.src = source; | |
| }else{ | |
| resizeIframe( 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
| window.addEvent('domready', function(){ | |
| function resizeIframe( iframe ){ | |
| var innerDoc = $( ( iframe.contentWindow ) ? iframe.contentWindow.document.body : iframe.contentDocument.body ) ); | |
| var objToResize = (iframe.style) ? iframe.style : iframe; | |
| var sizes = innerDoc.getSize(); | |
| var offsetHeight = sizes.scrollSize.y + 50; | |
| objToResize.height = offsetHeight + 'px'; | |
| } | |
| if( $('iframe') != null ){ | |
| var iframe = $('iframe'); | |
| iframe.addEvent('load', function(){ | |
| resizeIframe( this ); | |
| }); | |
| if( window.webkit || window.opera ){ | |
| var source = iframe.src; | |
| iframe.src = ''; | |
| iframe.src = source; | |
| }else{ | |
| resizeIframe( iframe ); | |
| } | |
| } | |
| }); |
Author
this sounds like the perfect solution to my problem, please can you tell a newbie where I must put this code to that it works ... I am using Jommla 1.7.
Thanks in advance!
Author
I'm glad this can help you, What I did is a file called iframe.js and added that to my template, It's always looking for an iframe with an id called "iframe" <iframe id="iframe" .....></iframe> and the script will just expand it, It has only 1 restriction the iframe must be on the same domain!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$('iframe') refers to all the elements marked with class iframe, this suits my needs change accordingly