js ▪ html5 /
正文
jquery 实现iframe 自适应高度
2024-01-13 23:29
2415 浏览
评论(0)
字体大小:
<iframe src="test.html" id="main" width="700" height="300" frameborder="0" scrolling="auto"></iframe>
jquery代码1:
注意:下面的代码是放在test.html调用
//注意:下面的代码是放在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同一个页面调用
//注意:下面的代码是放在和iframe同一个页面调用
$("#main").load(function(){
var mainheight = $(this).contents().find("body").height()+30;
$(this).height(mainheight);
});
本文发布于程序达人 ,转载请注明出处,谢谢合作
有 0 人认为有用
0 评论
共同学习,写下你的评论
相关热点文章推荐
Spring Boot文档翻译【转】
20661
2024-01-13 23:29
Spring Boot报java.lang.IllegalArgumentException:Property 'sqlSessionFactory' or 'sqlSessionTemplate'
16473
2024-01-13 23:29
SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe...
UploadiFive Documentation (api 说明文档)
9899
2024-01-13 23:29
svn: 目录中的条目从本地编码转换到 UTF8 失败 解决办法
5336
2024-01-13 23:29
解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile办法
4393
2024-01-13 23:29
程序达人 - chengxudaren.com
一个帮助开发者成长的社区
相关文章