html中高度随内容变化而变化,iframe的高度随内容变化而变化的代码

叁歲伎倆 2022-10-06 10:55 291阅读 0赞

iframe框架高度随内容的变化而变化的代码。

function AutoIframe()

{

if(document.readyState!=’complete’)

{

setTimeout( function(){AutoIframe();},25 );

return;

}

else

{

var ifobj=document.getElementById(“frmsrc”);

ifobj.height= ifobj.contentWindow.document.body.scrollHeight;

}

}

//PS: XXX.htm不可跨域

function SetWinHeight(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;

}

}

}

发表评论

表情:
评论列表 (有 0 条评论,291人围观)

还没有评论,来说两句吧...

相关阅读