first off, I have very very basic knowledge of Javascript and outdated knowledge of HTML, so I've been copying and pasting like a fiend trying to get this to work.
this is the code I'm currently using: (based on https://stackoverflow.com/a/819455/3005885)
<script language="JavaScript">
<!--
function autoResize(id){
var newheight;
var newwidth;
if(document.getElementById){
newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
}
document.getElementById(id).height= (newheight) + "px";
document.getElementById(id).width= (newwidth) + "px";
}
//-->
</script>
<iframe id="iframe1" name="iframe1" src="source.html" width="100%" frameborder="0" onLoad="autoResize('iframe1');"></iframe>
I have a CSS/Javascript row of "buttons" which move you to different pages on the site, and on the page in question there is an iframe and a series of links contained in a table (for organizational purposes). When you first click on the "button" for the page in question the iframe is showing up at a minimal height, until you click on the "button" again, and then the resizing behaves normally.
I've been trying to get the script (actually, several different scripts) to control the iframe element, but it seems like the iframe has to "exist" before it'll listen to the script.
I'd like the page to load with the "source.html" page at full height in the iframe, and the iframe's height to be dictated by the other pages pointed at the iframe.
EDIT 1: I've just tried this approach: https://stackoverflow.com/a/526373/3005885 with the same results as before. Am I doing something else wrong? Something basic? The JS works perfectly, but only after clicking on the link to load the page the iframe is in a second time, clicking refresh/reload (or command-R) doesn't make a difference.
EDIT 2: Here's another method that behaves the same as the others I've mentioned, only this one disables the scrollbars even in the initial too-small-to-see-anything loading (https://www.ibm.com/developerworks/community/blogs/peteryim/entry/determining_the_iframe_height_based_on_its_content6?lang=en).