JS_同域下的ifream自适应高度和设置注意等
2012-08-10 22:05
141 查看
NO.1: 创建一个无边框的ifream.
<iframe src="ifream.html" frameborder="0" width="300" height="150" id="myframe1">
NO.2:设置ifream的背景.
在ifream.html里面写样式设置body的背景.
NO.3:使ifream的高度自适应.
在ifream.html内定义一个高度为250的DIV.
.main{background:#F00;height:200px}
<div id="main" class="main">1</div>
自己的页面内JS代码:
<iframe src="ifream.html" frameborder="0" width="300" height="150" id="myframe1">
NO.2:设置ifream的背景.
在ifream.html里面写样式设置body的背景.
NO.3:使ifream的高度自适应.
在ifream.html内定义一个高度为250的DIV.
.main{background:#F00;height:200px}
<div id="main" class="main">1</div>
自己的页面内JS代码:
function addEvent(id,en,fu){ if(id.addEventListener){ id.addEventListener(en,fu,false); }else if(id.attachEvent){ id.attachEvent("on"+en, fu); } } var if1 = document.getElementById("myframe1"); if(if1.Document){ addEvent(if1,"load",function(){ if1.height = if1.Document.documentElement.scrollHeight; }); }else if(if1.contentDocument){ addEvent(if1,"load",function(){ if1.height = if1.contentDocument.documentElement.scrollHeight; }); }
相关文章推荐
- 【前端H5】bootstrap-table表格插件使用js设置高度及高度自适应
- bootstrap 表格插件bootstrap-table的js设置高度及高度自适应
- js获取鼠标坐标,设置div的高度、位置、内容等,及注意要点
- js实现textarea高度根据内容自适应
- js监听textarea文本域变化使高度自适应
- HTML教程:如何设置Iframe自适应高度
- DIV高度自适应及应该注意的问题
- 支持android&ios高度自适应及JS相互调用的组件react-native-webview2
- 关于iframe的高度自适应问题(js)
- iframe中js创建dom,高度自适应
- js控制textarea文本域自适应高度
- js--easyUI--EasyUI的datagrid自适应高度
- 兼容主流浏览器的iframe自适应高度js脚本
- JS网页高度设置
- Telerik Kindo Grid 隐藏 Y 轴 滚动条(scroll )设置自适应高度
- 设置div 自适应高度和宽度
- 【HTML/JS】实现iFrame自适应高度,原来很简单!
- js实现高度自适应
- Android ImageView设置长度高度为wrap_content时高度根据图片比例自适应
- 项目开发中的一些注意事项以及技巧总结 基于Repository模式设计项目架构—你可以参考的项目架构设计 Asp.Net Core中使用RSA加密 EF Core中的多对多映射如何实现? asp.net core下的如何给网站做安全设置 获取服务端https证书 Js异常捕获