分享

iframe自适应高度问题

 gearss 2016-05-19
         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>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多