您的位置:首页 > Web前端 > JavaScript

iframe高度自动适应宽高的js (兼容FF)

2013-01-07 09:50 561 查看
在机票版本中应用了iframe,但FF对iframe的高度解析有问题,因此调用以下JS
function SetCwinHeight(){
var xunzou=document.getElementById(“xunzou”); //iframe id
if (document.getElementById){
if (xunzou && !window.opera){
if (xunzou.contentDocument && xunzou.contentDocument.body.offsetHeight){
xunzou.height = xunzou.contentDocument.body.offsetHeight;
}else if(xunzou.Document && xunzou.Document.body.scrollHeight){
xunzou.height = xunzou.Document.body.scrollHeight;
}
}
}
}
HTML调用
<iframe  width=”100%” id=”xunzou” onload=”Javascript:SetCwinHeight()” height=”1″ frameborder=”0″ src=”地址” scrolling=”no”></iframe>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: