View Full Version : iFrame Javascript resize with switch content menu

08-11-2005, 04:01 PM
Okay, here's the problem. I have this site I'm currently building, http://www.towpc.com/ke5ehi/, and I have an iFrame for the main content (controlled by the menu on the left - item's with a ' * ' haven't been made yet). When you load the satellite page, it resizes fine, but when you load the chaser-on-the-road > on-the-road page (which has the switch content menu), the javascript only sizes the iFrame to the collapsed menu state, so if you expand any of the items, the page is cut-off. Any help would be appreciated (I'm still not that good on some of this :) )

This is the onload handler for each page within the iFrame:

<body onload="if (parent.adjustIFrameSize)
parent.adjustIFrameSize(window);" topmargin=0 leftmargin=0>

This is the javascript for the main page:

<script type="text/javascript">
function adjustIFrameSize (iframeWindow) {
if (iframeWindow.document.height) {
var iframeElement = document.getElementById
iframeElement.style.height = iframeWindow.document.height + 'px';
iframeElement.style.width = iframeWindow.document.width + 'px';
else if (document.all) {
var iframeElement = document.all[iframeWindow.name];
if (iframeWindow.document.compatMode &&
iframeWindow.document.compatMode != 'BackCompat')
iframeElement.style.height =
iframeWindow.document.documentElement.scrollHeight + 'px';
iframeElement.style.width =
iframeWindow.document.documentElement.scrollWidth + 'px';
else {
iframeElement.style.height =
iframeWindow.document.body.scrollHeight + 'px';
iframeElement.style.width =
iframeWindow.document.body.scrollWidth + 'px';

08-13-2005, 10:55 PM
...is there a way to maybe get the javascript to read the expanded switch menu and set the iframe to that size?

08-15-2005, 01:15 AM
is there a way to set a manual document length and just make the iframe a pre-determined size?

08-15-2005, 02:38 AM
I use div tags and define the proportions in a css file. I imagine that you can define the dimensions of an iframe with and ID using css as well.

08-15-2005, 09:59 PM
I've re-done a little, but now it's all Dynamic Drive script, so I've continued this thread in the Dynamic Drive forum here (http://www.dynamicdrive.com/forums/showthread.php?p=15392#post15392)