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 * ...
随机推荐
- Opportunity Helper
using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; public class OpportunityHel ...
- 对Python语法简洁的贴切描述
很多人认为,Python与其他语言相比,具有语法简洁的特点.但这种简洁到底体现在哪些地方,很少有人能说清楚.今天看到一个对这一问题的描述,个人觉得很不错,原文如下: “Python语法主要用来精确表达 ...
- mysql的数据类型与表约束
数据类型 (详细数据类型请参考:http://www.runoob.com/mysql/mysql-data-types.html) 数字 整型 tinyint int bigint 小数: flo ...
- malloc、calloc、realloc函数说明
malloc 函数 #include <stdlib.h> void* malloc(int n); n为要分配的字节数,如果成功,返回获得空间的首地址,如果分配失败,则返回NULL,ma ...
- 【转】I2C总线相关知识
1. I2C access 1.1. I2C introduction I2C(Inter-Integrated Circuit)总线是由NXP恩智浦半导体公司在80年代开发的两线式串行总线,用来进行 ...
- hive 打印日志
hive -hiveconf hive.root.logger=INFO,console -e 'select 1' hive 打印log ,有时hive 在配置时默认不会将mapper reduce ...
- 构建工具——maven的补充
1.安装jar到本地仓库 有时候有部分jar由于在maven的中央仓库,只能引用本地的,可以将jar安装到本地仓库进行操作(请先确保mvn命令可以正常运行) mvn install:install-f ...
- 北京Uber优步司机奖励政策(3月26日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 成都Uber优步司机奖励政策(2月7日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- day 3 list列表生成式
1.定义一个list列表,里面元素是0-33 a = [] i = 0 while i<33: a.append(i) i+=1 print(a) [0, 1, 2, 3, 4, 5, 6, 7 ...