您的位置:首页 > 其它

让Iframe自动适应高度,可以设置最小高度

2013-01-04 08:45 375 查看
//让Iframe自动适应高度
function SetWinHeight(obj)
{
var win=obj;
if (document.getElementById)
{
if (win && !window.opera)
{
if (win.contentDocument && win.contentDocument.body.offsetHeight)
{
if(win.contentDocument.body.offsetHeight<420){
win.height = 420;//设置最小高度
}else{
win.height = win.contentDocument.body.offsetHeight;
}
}
else if(win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}
}
}

html标签:

<iframe name="dtl" id="dtl" src="" onload="Javascript:SetWinHeight(this)" height="100%" width="100%" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="auto"></iframe>

onload="Javascript:SetWinHeight(this)"一定要有
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: