Resize iframe based on Content
Posted: Sun Jan 13, 2013 7:31 pm
No matter what I do I cannot seem to get this to work properly! All I want to do is simply adjust an iframe's size based on the content it loads. This is what I have at the moment. Any suggestions or help on how to get this to work? Also I want to use javascript and avoid jquery.
<script type="text/javascript" language="JavaScript"> <!-- function resizeIframeHeight(e){ if (e.Document && e.Document.body.scrollHeight) e.width = e.contentWindow.document.body.scrollHeight; else if (e.contentDocument && e.contentDocument.body.scrollHeight) e.width = e.contentDocument.body.scrollHeight + 35; else (e.contentDocument && e.contentDocument.body.offsetHeight) e.width = e.contentDocument.body.offsetHeight + 35; } //--> </script> <iframe id="iframe1" name="iframe1" src="..." width="100%" frameborder="0" scrolling="no" onload="resizeIframeHeight('iframe1')"></iframe>