Forum Moderators: open
ex.. i have set to height="370", which is fine for 800x600 res, but only 3/4 page filled with 1028x768 res... I want it so it auto fills any res chosen.
anybody help me with this?
site with iframe : <sorry, no personal URLs>
thx in advance! :)
[edited by: tedster at 12:28 pm (utc) on Jan. 21, 2003]
The only way you can do this is by dynamically setting the height/width using JavaScript.
You have two options:
1) Use the JS to check for screen resolution and then print the iframe to the page using document.write
2) Include the iframe like you normally would, but right after, put a JS that checks for screen size and change the size of the iframe if needed
Remember to check for the inner size of the window, not the inner size of the whole screen, since a lot of people (using monstrous monitors) only open smaller windows.
Also remember to have a default size (which should most likely be optimised for 800x600) since not all browsers/OS report the window size.
winWidth=document.all?document.body.clientWidth:window.innerWidth;
winHeight=document.all?document.body.clientHeight:window.innerHeight;
<iframe id="myIFrame" style="height:200px;width:400px;" src="example.html"></iframe>
<script type="text/javascript">
var MZ=(document.getElementById?true:false);
var IE=(document.all?true:false);
var winWidth=IE?document.body.clientWidth:window.innerWidth;
var winHeight=IE?document.body.clientHeight:window.innerHeight;
if(winHeight>500){
if(IE){
document.all['myIFrame'].style.height="300px";
}
else if(MZ){
document.getElementById('myIFrame').style.height="300px";
}
}
</script>
This is the code I have:
<iframe id="myIFrame" style="height:370;width:100%;" src="news.html" name="main" marginwidth="0" framespacing="0" marginheight="0" frameborder="0"></iframe>
<script type="text/javascript">
var MZ=(document.getElementById?true:false);
var IE=(document.all?true:false);
var winWidth=IE?document.body.clientWidth:window.innerWidth;
var winHeight=IE?document.body.clientHeight:window.innerHeight;
if(winHeight>500){
if(IE){
document.all['myIFrame'].style.height="370px";
}
else if(MZ){
document.getElementById('myIFrame').style.height="370px";
}
}
</script>
i've just worked out that me having the iframe in a table is killing the height attribute....only shows about 15% height!?
<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center">
<iframe id="myIFrame" style="height:370;width:100%;" src="news.html" name="main" marginwidth="0" framespacing="0" marginheight="0" frameborder="0"></iframe>
<script type="text/javascript">
var MZ=(document.getElementById?true:false);
var IE=(document.all?true:false);
var winWidth=IE?document.body.clientWidth:window.innerWidth;
var winHeight=IE?document.body.clientHeight:window.innerHeight;
if(winHeight>500){
if(IE){
document.all['myIFrame'].style.height="100%";
}
else if(MZ){
document.getElementById('myIFrame').style.height="100%";
}
}
</script>
</td>
</tr>
</table>