Created
January 31, 2012 20:08
-
-
Save longlostnick/1712614 to your computer and use it in GitHub Desktop.
Cross browser iframe scrollWidth/scrollHeight and resize iframe to content
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
// Works for me in IE7+, Webkit, and FF | |
function resizeToContent(frame_id) { | |
var my_frame = document.getElementById(frame_id); | |
var content_width = my_frame.contentWindow.document.documentElement.scrollWidth; | |
var content_height = my_frame.contentWindow.document.documentElement.scrollHeight; | |
my_frame.style.width = content_width + 'px'; | |
my_frame.style.height = content_height + 'px'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!
Finally found the solution for my problem! 😊