iframe 随内容自适应高度
兼容性好的
html代码:
<iframe src="enterprise/enter_edit.aspx" id="mainframe" frameborder="0" name="main"
onload="resize()" onreadystatechange="resize()" style="width: 100%; height: 100%;" border="0"></iframe>
JS代码:
<script type="text/javascript">
//iframe自适应高度的函数
var oTime = null;
function resize() {
if (oTime) {
clearTimeout(oTime);
}
oTime = setTimeout(reset, 0);
} //iframe自适应高度的函数
function reset() {
var frame = document.getElementById("mainframe");
var outHeight = frame.offsetHeight;
var inHeight = frame.contentWindow.document.body.scrollHeight;
if (outHeight < inHeight) {
frame.style.height = (inHeight + 10) + "px";
} else if (inHeight > 650) {
frame.style.height = (inHeight + 10) + "px";
} else {
frame.style.height = "750px";
}
}
</script>
jquery代码:
<script type="text/javascript">
//iframe 随内容自适高度
$("#mainframe").load(function () {
var mainheight = $(this).contents().find("body").height() + 30;
$(this).height(mainheight);
});
</script>
iframe 随内容自适应高度的更多相关文章
- Jquery实现textarea根据文本内容自适应高度
本文给大家分享的是Jquery实现textarea根据文本内容自适应高度,这些在平时的项目中挺实用的,所以抽空封装了一个文本框根据输入内容自适应高度的插件,这里推荐给小伙伴们. autoTextare ...
- html5 textarea 文本框根据输入内容自适应高度
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- iframe内容自适应高度
一直觉得要用JS才能实现iframe高度的自适应,其实CSS也可以,而且实现的更好,只是需要给包裹iframe的DIV设置个高度,然后让irame高度设置成100%就可以自适应了. 完美版Iframe ...
- IOS UILabel 根据内容自适应高度
iOS Label 自适应高度 适配iOS7以后的版本 更多 self.contentLabelView = [[UILabel alloc] init]; self.contentLabelVie ...
- ios label根据内容自适应高度
label自适应高度,想必大家也都很熟悉怎么去做,上代码: UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(150, 50, 15 ...
- MiniUi遇到的一个Bug或者说坑,以div里面的内容自适应高度
页面源码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...
- iframe框根据内容自适应高度
1.页面 <iframe name="iframe_userCenter" id="iframe" frameborder=2 width=100% he ...
- iframe 如何让它展现内容自适应高度
引用: <iframe id="ifm1" runat="server" src="/comment/page1?id=@productId&q ...
- iOS开发-UITextView根据内容自适应高度
UITextView作为内容文本输入区域,有的时候我们需要根据内容动态改变文本区域的高度,效果如下: 定义UITextView,实现UITextViewDelegate: -(UITextView * ...
随机推荐
- python学习笔记~INI、REG文件读取函数(自动修复)
引入configparser,直接read整个INI文件,再调用get即可.但需要注意的是,如果INI文件本身不太规范,就会报各种错,而这又常常不可避免的.本文自定义函数通过try...except. ...
- Java语法糖 : try-with-resources
先了解几个背景知识 什么是语法糖 语法糖是在语言中增加的某种语法,在不影响功能的情况下为程序员提供更方便的使用方式. 什么是资源 使用之后需要释放或者回收的都可以称为资源,比如JDBC的connect ...
- vs2013工程配置
1. 目标文件生成路径配置: 直接改在工程同级目录下 x64\debug目录下: 2. 调试工程路径配置: 命令-----参照物为工程 工作目录----参照物为运行程序 3. 拷贝工程: bat的写 ...
- geoserver中WMS服务详细说明
官方geoserver中WMS服务中几种操作的API的详细说明地址: http://docs.geoserver.org/stable/en/user/services/wms/reference.h ...
- BZOJ2659_算不出的算式_KEY
题目传送门 其实打表找一找规律可以得出: /************************************************************** Problem: 2659 U ...
- 上海Uber优步司机奖励政策(1月11日~1月17日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- LVS Nginx HAProxy
转自:http://blog.chinaunix.net/uid-27022856-id-3236257.html LVS 优点:1.抗负载能力强.工作在第4层仅作分发之用,没有流量的产生,这个特点也 ...
- HIS系统两种收费模式比较:前计费和后计费
一.药品 a.前计费:审核(临时医嘱)或者分解(长期医嘱)计费 退费处理方式,1)如果是还未发药,则护士站直接退费;2)如果药房已经发药,则护士站发出退费申请,由护士拿着药品去药房退药退费. b.后计 ...
- Use GitHub Desktop to get GitHub projects
Find the project's https git file in the home page of the project. e.g. https://github.com/PrismLibr ...
- Unity Lighting - Lighting overview 照明概述
Lighting overview 照明概述 In order to calculate the shading of a 3D object, Unity needs to know the ...