IFRAME自动适应的问题
2007-08-27 08:27
211 查看
iframe src="show.htm" id="show" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" width="100%" onload="this.height=0;var fdh=(this.Document?this.Document.body.scrollHeight:this.contentDocument.body.offsetHeight);this.height=(fdh>7?fdh:7)"></iframe>
注:onload字段中的数值“7”为Iframe最低高度值,可自定义!
另外这个同时支持IE&Firefox:)
PS:如果内页的CSS设置了BODY的MARGIN属性,IFRAME自适应的高度不会把margin-top和margin-bottom的值加到里面,所以最后这地方this.height=(fdh>450?fdh:400)得改成
this.height=(fdh>450?fdh+margin-top的高度+margin-bottom的高度:400)
比如说
this.height=(fdh>450?fdh+20+15:400) //尚未测试
注:onload字段中的数值“7”为Iframe最低高度值,可自定义!
另外这个同时支持IE&Firefox:)
PS:如果内页的CSS设置了BODY的MARGIN属性,IFRAME自适应的高度不会把margin-top和margin-bottom的值加到里面,所以最后这地方this.height=(fdh>450?fdh:400)得改成
this.height=(fdh>450?fdh+margin-top的高度+margin-bottom的高度:400)
比如说
this.height=(fdh>450?fdh+20+15:400) //尚未测试
相关文章推荐
- IFRAME自动适应的问题
- 本地测试:iframe高度自动适应在chrome无效的问题
- IFRAME自动适应的问题
- ExtJS嵌入网页要解决iframe自动适应窗体大小的问题
- IFRAME自动适应的问题
- iframe 自动适应高和宽问题 和 其他Frame操作技巧
- 自动适应Iframe
- Iframe自动适应高度
- 探究客户端浏览器分辨率的自适应问题(如何使网站脚本自动适应客户端分辨率)(2)
- Iframe自动适应宽度和高度
- iframe自动适应页面
- Iframe自动适应宽度和高度(both IE and Firefox )
- iframe自动适应高度及iframe中含有页签的高度动态适应方法
- Iframe自动适应宽度和高度
- 如何使IFrame的长宽与内容自动适应大小
- Iframe 自动适应页面的高度示例代码
- 如何使IFrame的长宽与内容自动适应大小
- iframe高度适应内容相关问题
- JS怎么控制IFRAME高度自动适应内容而不出现滚动条
- iframe的自动延伸问题