iframe自适高度宽度,多版本浏览器兼容

别等时光非礼了梦想. 提交于 2020-01-30 08:55:46

<script type="text/javascript">
function SetCwinHeight() {
var iframeid = document.getElementById("maincontent1"); //iframe id
iframeid.height = "10px";//先给一个够小的初值,然后再长高.
if (document.getElementById) {
if (iframeid && !window.opera) {
if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight) {
iframeid.height = iframeid.contentDocument.body.offsetHeight;
} else if (iframeid.Document && iframeid.Document.body.scrollHeight) {
iframeid.height = iframeid.Document.body.scrollHeight;
}
}
}
}
</script>

 

<iframe style="z-index: 1; visibility: inherit; width: 100%; position:absolute; top:0px; left:0px;" name="maincontent1" onload="Javascript:SetCwinHeight()" height="1" id="maincontent1"marginwidth="0" marginheight="0" frameborder="0" scrolling="no"  src="topTemplate.html"></iframe>

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!