Answer by David Bradshaw for Resizing an iframe based on content
Answer in 2024It has been 15 years since this question was first asked and browsers still struggle with this issue. Modern browsers have come along way since then, but still don't have a simple...
View ArticleResizing an iframe based on content
I am working on an iGoogle-like application. Content from other applications (on other domains) is shown using iframes. How do I resize the iframes to fit the height of the iframes' content?I've tried...
View ArticleAnswer by roryf for Resizing an iframe based on content
This is slightly tricky as you have to know when the iframe page has loaded, which is difficuly when you're not in control of its content. Its possible to add an onload handler to the iframe, but I've...
View ArticleAnswer by Ólafur Waage for Resizing an iframe based on content
Something on the lines of this i belive should work.parent.document.getElementById(iFrameID).style.height=framedPage.scrollHeight;Load this with your body onload on the iframe content.
View ArticleAnswer by Macho Matt for Resizing an iframe based on content
The solution on http://www.phinesolutions.com/use-jquery-to-adjust-the-iframe-height.html works great (uses jQuery):<script type=”text/javascript”> $(document).ready(function() { var theFrame =...
View ArticleAnswer by Joeri Sebrechts for Resizing an iframe based on content
iGoogle gadgets have to actively implement resizing, so my guess is in a cross-domain model you can't do this without the remote content taking part in some way. If your content can send a message with...
View ArticleAnswer by ConroyP for Resizing an iframe based on content
We had this type of problem, but slightly in reverse to your situation - we were providing the iframed content to sites on other domains, so the same origin policy was also an issue. After many hours...
View ArticleAnswer by Ahmy for Resizing an iframe based on content
If you do not need to handle iframe content from a different domain, try this code, it will solve the problem completely and it's simple:<script language="JavaScript"><!--function...
View ArticleAnswer by Vaughan Rowsell for Resizing an iframe based on content
Here is a simple solution using a dynamically generated style sheet served up by the same server as the iframe content. Quite simply the style sheet "knows" what is in the iframe, and knows the...
View ArticleAnswer by Chris Jacob for Resizing an iframe based on content
https://developer.mozilla.org/en/DOM/window.postMessagewindow.postMessage()window.postMessage is a method for safely enabling cross-origin communication. Normally, scripts on different pages are only...
View ArticleAnswer by kaw for Resizing an iframe based on content
When you want to zoom out a web page to fit it into the iframe size:You should resize the iframe to fit it with the contentThen you should zoom out the whole iframe with the loaded web page contentHere...
View ArticleAnswer by فيصلخلبوص for Resizing an iframe based on content
I have an easy solution and requires you to determine the width and height in the link, please try (It works with most browsers):<a href='#' onClick="...
View ArticleAnswer by Tor Händevik for Resizing an iframe based on content
I'm implementing ConroyP's frame-in-frame solution to replace a solution based on setting document.domain, but found it to be quite hard determining the height of the iframe's content correctly in...
View ArticleAnswer by Omer Arshad for Resizing an iframe based on content
The simplest way using jQuery:$("iframe").attr({"scrolling": "no", "src":"http://www.someotherlink.com/"}).load(function() { $(this).css("height", $(this).contents().height() +"px");});
View ArticleAnswer by chad steele for Resizing an iframe based on content
Here's a jQuery approach that adds the info in json via the src attribute of the iframe. Here's a demo, resize and scroll this window.. the resulting url with json looks like this......
View ArticleAnswer by webd3sign for Resizing an iframe based on content
<html><head><script>function frameSize(id){var frameHeight;document.getElementById(id).height=0 +"px";if(document.getElementById){...
View ArticleAnswer by YellowGlue for Resizing an iframe based on content
get iframe content height then give it to this iframe var iframes = document.getElementsByTagName("iframe"); for(var i = 0, len = iframes.length; i<len; i++){ window.frames[i].onload = function(_i){...
View ArticleAnswer by ddlab for Resizing an iframe based on content
may be a bit late, as all the other answers are older :-) but... here´s my solution. Tested in actual FF, Chrome and Safari 5.0.css:iframe {border:0;...
View ArticleAnswer by Selvamani for Resizing an iframe based on content
Finally I found some other solution for sending data to parent website from iframe using window.postMessage(message, targetOrigin);. Here I explain How I did.Site A = http://foo.comSite B =...
View ArticleAnswer by Mario Gonzales Flores for Resizing an iframe based on content
Work with jquery on load (cross browser):<iframe src="your_url" marginwidth="0" marginheight="0" scrolling="No" frameborder="0" hspace="0" vspace="0" id="containiframe" onload="loaderIframe();"...
View Article