一直觉得要用JS才能实现iframe高度的自适应,其实CSS也可以,而且实现的更好,只是需要给包裹iframe的DIV设置个高度,然后让irame高度设置成100%就可以自适应了。
完美版Iframe自适应高度====>推荐使用 <!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>iframe高度自适应</title>
<style>
*{margin:0; padding:0;}
html,body{height:100%;}
.header{width: 100%;height:50px;background: #11c1f3; }
.container{padding:0 0 0 200px;overflow: hidden;}
.container .main{position:absolute; width:auto; height:auto; top:50px; left:200px; right:0; bottom:0; overflow:hidden;}
.container .left{width:200px; height:auto; background:#ef473a; position:absolute; left:0; top:50px; bottom:0; overflow: auto;}
</style>
</head>
<body> <div class="header">顶部导航区域...</div>
<div class="container">
<div class="main">
<iframe class="mainFrame" src="http://www.cnblogs.com/leyi" width="100%" height="100%" frameborder="0"></iframe>
</div>
<div class="left">左侧导航区域...</div>
</div>
</body>
</html>
 table版Iframe自适应高度打造高度自适应的后台布局框架=====> 

<style>
*{ margin:0; padding:0}
body, html{ height:100%; width:100%; overflow:hidden;} /*这个高度很重要*/
#frametable .header{ height:40px; background:#ddd; border-bottom:2px solid #999;}
#frametable .left{ width:150px; border-right:2px solid #999; background:#ddd; height:100%;}
</style> <table id="frametable" cellpadding="0" cellspacing="0" width="100%" height="100%" style="width: 100%;">
<tr>
<td colspan="2" height="40">
<div class="header">
<!-- header menu -->
</div>
</td>
</tr>
<tr>
<td valign="top" width="150" height="100%"> <!--这个高度很重要-->
<div class="left"><!-- left menu --></div>
</td>
<td valign="top" width="100%" height="100%"> <!--这个高度很重要-->
<iframe id="iframe" name="main" src="http://www.baidu.com" width="100%" allowtransparency="true" width="100%" height="100%" frameborder="0" scrolling="yes" style="overflow:visible;"></iframe>
</td>
</tr>
</table>

操作iframe=====>

    contentWindow //所有浏览器都支持的
contentDocument //ie 6 7 不支持
document.getElementById('iframe_id').contentWindow.document.getElementById('子页面元素节点');
window.parent //子frame操作父级页面
window.parent.document.getElementById('父页面元素节点').style.cssText=..
window.top //获取最顶层一级页面
window.top.document.getElementById('最顶层页面元素节点').style.cssText=..
//防止被嵌套:
if(window!=window.top){
window.top.location.href=window.location.href
}
iframe的传值方式=====>
1、jsonp
2、localstorage
3、postMessage

  

  

iframe内容自适应高度的更多相关文章

  1. Jquery实现textarea根据文本内容自适应高度

    本文给大家分享的是Jquery实现textarea根据文本内容自适应高度,这些在平时的项目中挺实用的,所以抽空封装了一个文本框根据输入内容自适应高度的插件,这里推荐给小伙伴们. autoTextare ...

  2. jQuery实现iframe的自适应高度

    假设我们在当前页面要嵌套一个iframe 1 <iframe id="myframe" src="test.html" height="240& ...

  3. html5 textarea 文本框根据输入内容自适应高度

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  4. iframe 随内容自适应高度

    兼容性好的 html代码: <iframe src="enterprise/enter_edit.aspx" id="mainframe" framebo ...

  5. iframe框架自适应高度 uncanght SecurityError: Blocked a frame with origin "null" from accessing a frame ....

    来源于crm项目的contact/edit.html 一.背景是这样的 最近在做crm系统的前端页面,有一个页面呢,点击“查看全部信息”时会弹出,这个弹窗里面又有分页导航,分页不是使用ajax 异步刷 ...

  6. IOS UILabel 根据内容自适应高度

    iOS Label 自适应高度  适配iOS7以后的版本 更多 self.contentLabelView = [[UILabel alloc] init]; self.contentLabelVie ...

  7. 关于使用iframe标签自适应高度的使用

    在ifrome内设定最小高度,(此方法只适用于页面内切换高度不一.但是会保留最大高度,返回后保持最大高度不再回到最初页面的高度) <iframe id="one4" widt ...

  8. ios label根据内容自适应高度

    label自适应高度,想必大家也都很熟悉怎么去做,上代码: UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(150, 50, 15 ...

  9. MiniUi遇到的一个Bug或者说坑,以div里面的内容自适应高度

    页面源码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...

随机推荐

  1. python 的基础 学习 第一天

    1 python 的变量 1,变量必须 由数字,字母和下划线组成 2,变量不能由数字开头,例如 :22hhh , 3,变量不能是由Python中的关键字组成. 4,变量具有可描述性,不易过长. 5,变 ...

  2. 将本地项目上传到git

    1.新建一个README.md的文件,并将项目名写入此文件(一般第三方git服务会在创建在创建项目的时候自动创建该文件,可以跳过这一步) echo "# Lee" >> ...

  3. 二叉查找树(Binary Search Tree)

    二叉树的一个重要的应用是他们在查找中的使用. 以下是二叉查找树的查找代码 #include <stdio.h> int main() { typedef struct Node{ int ...

  4. 超级简单的Android Studio jni 实现(无需命令行)【转载】

    原文: http://www.jianshu.com/p/e689d0196a17 1.配置Anroid Studio(这步是关键) 使用[command+,] 打开Preferences,选择Ext ...

  5. 2017-2018-2 20165325 实验一《Java开发环境的熟悉》实验报告

    一.Java开发环境的熟悉-1 1.实验要求: 0 参考实验要求: 1 建立"自己学号exp1"的目录 : 2 在"自己学号exp1"目录下建立src,bin等 ...

  6. Elasticsearch 5.4.3实战--Java API调用:批量写入数据

    这个其实比较简单,直接上代码. 注意部分逻辑可以换成你自己的逻辑 package com.cs99lzzs.elasticsearch.service.imp; import java.sql.Tim ...

  7. 【运维】Dell R710如何做Raid0与Raid5

    [写在前面]         这次是在戴尔服务器R710上面尝试的做Raid0和Raid5,亲测成功.         因为创建Raid0与Raid5的方式是一样的,所以就以创建Raid5为例. 1, ...

  8. dubbo源码分析4——SPI机制_ExtensionFactory类的作用

    ExtensionFactory的源码: @SPI public interface ExtensionFactory { /** * Get extension. * * @param type o ...

  9. 竞赛常用STL备忘录

    __builtin: __builtin_popcount:二进制中 1 的个数__builtin_ctz:末尾的 0,即对 lowbit 取log__builtin_clz:开头的 0,用 31 减 ...

  10. 用Cordova打包Vue-vux项目

    技术搭建:vue + vux 首先推荐阅读这篇文章,写的已经很详细了:https://www.jianshu.com/p/25d797b983cd 此处记录下我按照这篇文章打包的时候报的一些错误,方便 ...