惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
V
Vulnerabilities – Threatpost
C
CERT Recently Published Vulnerability Notes
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
Y
Y Combinator Blog
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Project Zero
Project Zero
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
MyScale Blog
MyScale Blog
Security Latest
Security Latest
T
Threat Research - Cisco Blogs
量子位
I
Intezer
Simon Willison's Weblog
Simon Willison's Weblog
C
Cybersecurity and Infrastructure Security Agency CISA
L
Lohrmann on Cybersecurity
L
LINUX DO - 最新话题
The Register - Security
The Register - Security
T
Tailwind CSS Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
T
Troy Hunt's Blog
Stack Overflow Blog
Stack Overflow Blog
Cloudbric
Cloudbric
S
Secure Thoughts
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
L
LangChain Blog
Recorded Future
Recorded Future
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Tor Project blog
人人都是产品经理
人人都是产品经理
F
Full Disclosure
O
OpenAI News
Webroot Blog
Webroot Blog
A
Arctic Wolf
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
H
Heimdal Security Blog
B
Blog RSS Feed
Vercel News
Vercel News

博客园 - 沧海一声笑

阿里云服务器被挖矿minerd入侵的解决办法 Visor 隐藏应用之一 CSS3 生成器 Visro 应用的前端模板工具介绍 -JsRender 如何在HTML5 Canvas 里面显示 Font Awesome 图标 visor 发布 在一个老外微信PM的眼中,中国移动App UI那些事儿 7个步骤:让JavaScript变得更好 Websocket 协议解析 HTML5全局属性和事件 HTML5适合移动应用开发的几大特性 JQuery 应用-JQuery.groupTable.js(二) JQuery 应用-JQuery.groupTable.js - 沧海一声笑 - 博客园 DataGridView控件用法合集 .Net 字符串编码和转换 浅析ASP.NET 3.5与ASP.NET 4.0主要差别 单点登录的实现思路(转) 中国惠普前总裁孙振耀的毕生经验之谈 jquery之旅-jquery的Ajax SQL Server 2008 对 T-SQL 语言的增强
jquery 实现iframe 自适应高度
沧海一声笑 · 2010-04-06 · via 博客园 - 沧海一声笑

超级简单的方法,也不用写什么判断浏览器高度、宽度啥的。
下面的两种方法自选其一就行了。一个是放在和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);
});

子页面调用父页面js函数:
top.alertstr(’我是子页面’);

子页面调用兄弟页面js函数:
top.$(”#b”).alertstr(’我是子页面’);
“#b”是指兄弟页面的ID