在点击 left.aspx 页面的时候 名字为zuo的iframe 随他点击页面的高度来变换 iframe (zuo)的高度
<table width= "775 " border= "0 " height= "100% " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td height= "4 " colspan= "3 "> </td>
</tr>
<tr>
<td width= "160 " valign= "top ">
<iframe src= "left.aspx " name= "change " width= "100% " height= "100% " scrolling= "no " frameborder= "NO " id= "change "> </iframe> </td>
<td width= "5 ">
</td>
<td align= "center " valign= "top " bgcolor= "#DEEFEF ">
<iframe src= " " name= "zuo " width= "100% " height= "100% " scrolling= "no " frameborder= "NO " id= "Iframe2 "> </iframe> </td>
</tr>
</table>
------解决方案--------------------------------------------------------
在使用iframe时,需指定高度,但如果iframe里面的页面的内容有所变化时
可能原来指定的高度不够,怎么办?
<iframe name= "left_frame " frameborder= "0 " src= "left.jsp " width= "140 " scrolling= "no " height= "1000 "> </iframe>
解决办法就是往iframe内容的页面里面加上下面一段javascript:
<SCRIPT language=javascript>
function window.onload() {
if(top.location != self.location){
var a = window.parent.document.getElementsByTagName( 'iframe ');
for (var i=0; i <a.length; i++){
if (a[i].name == self.name) {a[i].height = document.body.scrollHeight; return;}}}
}
</script>
------解决方案--------------------------------------------------------
更好的
<script language= "Javascript ">
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf( "Firefox ")).split( "/ ")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion> =0.1? 16 : 0
function dyniframesize(iframename) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(iframename);
}
else{
eval( 'pTar = ' + iframename + '; ');
}
if (pTar && !window.opera){
//begin resizing iframe
pTar.style.display= "block "
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight;
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
}
}
}
</script>
<iframe id= "myTestFrameID "
onload= "javascript:{dyniframesize( 'myTestFrameID ');} "
marginwidth=0 marginheight=0 frameborder=0
scrolling=no src= "/myiframesrc.php "