关闭

iframe自适应高度

305人阅读 评论(0) 收藏 举报
分类:
 <div>

       <iframe name="iframe1" id="iframe1" onload="dyniframesize1(this)" >

<html>

<div>

<button1 onclick="dyniframesize2(window.parent.document.getElementById("iframe1"))">

<buttononclick="dyniframesize2(window.parent.document.getElementById("iframe1"))">

</div>

<div>

<tab1 height="100px;">

<tab2 height="200px;">

</div>

</html>

</iframe>

    </div>

//ifram外部改变自适应高度
function dyniframesize1(obj){
var win=obj;
if (document.getElementById){
if (win && !window.opera){
if (win.contentDocument && win.contentDocument.body.offsetHeight)
win.height = win.contentDocument.body.offsetHeight;
else if(win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}
}
}


//ifram内部改变自适应高度
function dyniframesize2(obj){
var win=obj;
if (window.parent.document.getElementById){
if (win && !window.parent.window.opener){
if (win.contentDocument && win.contentDocument.body.offsetHeight)
win.height = win.contentDocument.body.offsetHeight;
else if(win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}
}
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:6673次
    • 积分:171
    • 等级:
    • 排名:千里之外
    • 原创:10篇
    • 转载:4篇
    • 译文:0篇
    • 评论:0条
    文章分类