body 适应ifram 高度
<!--Iframe自适应其加载的内容高度-->
<script type="text/javascript">
function iframeAutoFit()
{
try
{
if(window!=parent)
{
var a = parent.document.getElementsByTagName("IFRAME");
for(var i=0; i<a.length; i++) //author:meizz
{
if(a[i].contentWindow==window)
{
var h = document.body.scrollHeight;
if(document.all) {h += 4;}
if(window.opera) {h += 1;}
a[i].style.height = h;
}
}
}
}
catch (ex)
{
alert("脚本无法跨域操作!");
}
}
if(document.attachEvent) window.attachEvent("onload", iframeAutoFit);
else window.addEventListener('load', iframeAutoFit, false);
</script>
function my_init()
{
minHeight = document.getElementById("listWindow").offsetHeight;
minWidth = document.getElementById("listWindow").offsetWidth;
}
function resizeHeight(h, w)
{
h += 40;
// if (w) {w += 20;}
if (h>minHeight) {document.all.listWindow.style.height = h;}
if (w && w>minWidth) {document.all.listWindow.style.width = w;}
// if (parent && parent.resizeHeight) {parent.resizeHeight(document.body.scrollHeight);}
}
ifram 页面
function my_init()
{
if (parent && parent.resizeHeight) {parent.resizeHeight(document.body.scrollHeight);}
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步