iframe高度自适应
来源:互联网 发布:如何抓取网页数据 编辑:程序博客网 时间:2024/05/24 01:50
超级简单的方法,也不用写什么判断浏览器高度、宽度啥的。
下面的两种方法自选其一就行了。一个是放在和iframe同页面的,一个是放在test.html页面的。
注意别放错地方了哦。
iframe代码,注意要写ID
<iframe src="test.html" id="main" width="700" height="300" frameborder="0" scrolling="auto"></iframe>
jquery代码1:
//注意:下面的代码是放在test.html调用
$(window.parent.document).find("#main").load(function(){
var main = $(window.parent.document).find("#main");
var thisheight = $(document).height()+30;
main.height(thisheight);
});
jquery代码2:
//注意:下面的代码是放在和iframe同一个页面调用
$("#main").load(function(){
var mainheight = $(this).contents().find("body").height()+30;
$(this).height(mainheight);
});
下面的两种方法自选其一就行了。一个是放在和iframe同页面的,一个是放在test.html页面的。
注意别放错地方了哦。
iframe代码,注意要写ID
<iframe src="test.html" id="main" width="700" height="300" frameborder="0" scrolling="auto"></iframe>
jquery代码1:
//注意:下面的代码是放在test.html调用
$(window.parent.document).find("#main").load(function(){
var main = $(window.parent.document).find("#main");
var thisheight = $(document).height()+30;
main.height(thisheight);
});
jquery代码2:
//注意:下面的代码是放在和iframe同一个页面调用
$("#main").load(function(){
var mainheight = $(this).contents().find("body").height()+30;
$(this).height(mainheight);
});
0 0
- Iframe高度自适应
- iframe 的自适应高度
- 是Iframe高度自适应
- iframe 的自适应高度
- iframe自适应高度
- Iframe自适应高度
- 让IFRAME自适应高度
- Iframe 自适应高度宽度
- iframe自适应高度
- iframe自适应高度
- Iframe自适应高度[摘]
- 让Iframe自适应高度
- IFRAME自适应高度
- iframe自适应高度[转]
- iframe自动自适应高度
- iframe 自适应高度
- Iframe自适应高度
- iframe自适应高度
- poj 3903 求最长上升子序列长度
- hdu 4473 Exam
- hdu1625
- IOS,[UILabel copyWithZone:]: 的解决方法
- window下安装memcached
- iframe高度自适应
- Re-installation failed due to different application signatures.解决方案
- Mybatis基础入门(四)——与springMVC的集成
- HDU Redraw Beautiful Drawings 判断最大流是否唯一解
- POJ 线段树总结
- CI中使用memcached
- hdu 3486 Interviewe
- 使用plist创建动画
- POJ 1166 敌兵布阵