手机
当前位置:查字典教程网 >网页设计 >脚本HTML教程 >iframe的高度随内容变化而变化的代码
iframe的高度随内容变化而变化的代码
摘要:iframe框架高度随内容的变化而变化的代码。iframesrc="XXX.htm"width="700px"frameborder="0"...

iframe框架高度随内容的变化而变化的代码。iframe src="XXX.htm" width="700px" frameborder="0" scrolling="no" marginheight="0" onload="AutoIframe()"/iframe

script type="text/javascript"

function AutoIframe()

{

if(document.readyState!='complete')

{

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

return;

}

else

{

var ifobj=document.getElementById("frmsrc");

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

}

}

/script

//PS: XXX.htm不可跨域

iframe src="dd.html" name="frmMain" width="99%" height="100%" frameborder=0 scrolling=no marginHeight=0 marginWidth=0 onload="Javascript:SetWinHeight(this)" /iframe

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;

}

}

}

【iframe的高度随内容变化而变化的代码】相关文章:

HTML中Id和Name的区别

HTML 4.0 语法背景标签

iframe里面的页面调用父窗口,左右窗口js函数的方法

在Foxmail中直接查看HTML格式邮件

网页设计注意的问题

html常用的几个重定向连接示例代码

Visual Basic中如何处理HTML文档和剪贴板

html中的javascript 全选/取消全选操作示例代码

HTML标记大全参考手册

一个生成html的新方法

精品推荐
分类导航