iframe加载页面自适应高度,加载不同a标签的链接时高度固定在了最长的页面高度,这怎么调整?就是第一次加载时高度是自适应的,但是点击了其他a标签后,iframe高度就变成了其中页面最长的那个页面的高度,下面有很多空白。
<a href="mine.php?id=<?php echo $a ?>" target="mainframe">矿产产量</a>
<a href="right.php?id=<?php echo $a ?>" target="mainframe">简介</a>
<a href="geograpyh.php?id=<?php echo $a ?>" target="mainframe">地理</a>
<a href="people.php?id=<?php echo $a ?>" target="mainframe">人口和社会</a>
<a href="goverment.php?id=<?php echo $a ?>" target="mainframe">政治</a>
<a href="economy.php?id=<?php echo $a ?>" target="mainframe">经济</a>
<a href="communication.php?id=<?php echo $a ?>" target="mainframe">通讯</a>
<a href="transportation.php?id=<?php echo $a ?>" target="mainframe">交通</a>
<a href="military.php?id=<?php echo $a ?>" target="mainframe">军事</a>
<a href="energy.php?id=<?php echo $a ?>" target="mainframe">能源</a>
<iframe src="right.php?id=<?php echo $a ?>" name="mainframe" id="iframepage" frameborder="0" scrolling="yes" marginheight="0" width="100%" onload="iFrameHeight()" target="_self"></iframe>
<script type="text/javascript" language="javascript">
function iFrameHeight() {
var ifm= document.getElementById("iframepage");
var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;
if(ifm != null && subWeb != null) {
ifm.height = subWeb.body.scrollHeight;
}
}
</script>
|