Forum Moderators: open

Message Too Old, No Replies

Parent/Child iframe height control via HTML&JS

         

Diakon

11:10 pm on Feb 22, 2004 (gmt 0)

10+ Year Member



I have a script that auto changes the height of an iframe through its ID. It works in IE4.0+ without a problem but the heights wount work in NN.

This is the script that i use, which works in IE.

parent.document.getElementById("info2").height=document.getElementById("table").height;
parent.document.getElementById("info2").width=document.getElementById("table").width;

i have tried the following for NN, and still no results.

parent.document.layers["info2"].height=document.layers["table"].height;
parent.document.layers["info2"].width=document.layers["table"].width;
&
parent.document.all["info2"].height=document.layers["table"].height;
parent.document.all["info2"].width=document.layers["table"].width;

I believe im using the wrong NN id identification elements, does anyone have a Netsacpe Navigator solution?
Thank you!

isitreal

5:18 am on Feb 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You forgot the 'style' in your statement, it has to be document.getElementById('iframeContainer').style.height and style.width.

If that doesn't work, try this:

Try creating a div tag to hold the iframe, have the iframe sized to fill the div tag completely, by percents,
div#iframeContainer {width:500px;height:400px;}
iframe {width:100%;height:100%}

then use document.getElementById('iframeContainer').style.height = new height;
document.getElementById('iframeContainer').style.width = new width.

I just did this on one of my sites with the iframe div container and it works perfectly on mozilla/netscape all versions, opera 6 and 7, I think 5, and IE 5x and 6, also on safari.