手机
当前位置:查字典教程网 >网页设计 > Div+Css教程 >Iframe高度自适应代码
Iframe高度自适应代码
摘要:Iframe高度自适应IE与FF环境下均可用看下面的代码:scripttype="text/javascript"functionSetCw...

Iframe高度自适应IE与FF环境下均可用

看下面的代码:

scripttype="text/javascript"

functionSetCwinHeight(){

varbobo=document.getElementById("bobo");//iframeid

if(document.getElementById){

if(bobo!window.opera){

if(bobo.contentDocumentbobo.contentDocument.body.offsetHeight){

bobo.height=bobo.contentDocument.body.offsetHeight;

}elseif(bobo.Documentbobo.Document.body.scrollHeight){

bobo.height=bobo.Document.body.scrollHeight;

}

}

}

}

/scriptiframewidth="100%"id="bobo"onload="Javascript:SetCwinHeight()"height="1"frameborder="0"src="/"/iframe

查看运行效果:

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"html xmlns="/1999/xhtml"headmeta http-equiv="Content-Type" content="text/html; charset=utf-8" /titleIframe高度自适应 IE与FF环境下均可用/title/headbodyscript type="text/javascript"function SetCwinHeight(){var bobo=document.getElementById("bobo"); //iframe idif (document.getElementById){if (bobo !window.opera){if (bobo.contentDocument bobo.contentDocument.body.offsetHeight){bobo.height = bobo.contentDocument.body.offsetHeight;}else if(bobo.Document bobo.Document.body.scrollHeight){bobo.height = bobo.Document.body.scrollHeight;}}}}/scriptiframe width="100%" onload="Javascript:SetCwinHeight()" height="1" frameborder="0" src="/"/iframe/body/html

[ 可先修改部分代码 再运行查看效果 ]

【Iframe高度自适应代码】相关文章:

高效整洁CSS代码

[转]目前找到的最好的Iframe自适应高度代码

jsp页面iframe高度自适应的js代码

Iframe 自动适应页面的高度示例代码

兼容FIREFOX下背景层的自适应高度

Iframe 自适应高度并实时监控高度变化的js代码

CSS里随滚动条滚动代码

高效整洁CSS代码原则

jQuery解决iframe高度自适应代码

DIV+CSS网页设计常用布局代码

精品推荐
分类导航