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

推荐订阅源

爱范儿
爱范儿
博客园 - 【当耐特】
量子位
Engineering at Meta
Engineering at Meta
博客园_首页
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
V
Visual Studio Blog
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
Jina AI
Jina AI
The Cloudflare Blog
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
博客园 - 聂微东

博客园 - .net小鸟

产品很重要 JQUERY FAQ 无法打开到主机的连接,在端口xxx连接失败 eclipse的调试技术 js parseInt与排序 html到asp.net样式变乱 django学习资料 FAQ js工具类 python31操作MySql .net连接mysql maven下载地址 jquery操作ul notepad++中用正则表达式 jquery 两个控件同享一个function javascript 经常会用到的东西 javascript template javascript closure anonymous function javafirststep
jquery iframe 父子互操作
.net小鸟 · 2011-08-23 · via 博客园 - .net小鸟

父页面

View Code

<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
function(){
$(
"#btn").click(function(){
    
var sondocument = $(window.frames[0].document)
    alert(sondocument.find(
"#smsg").html());
})});
</script>
</head>
<body>
<div>below me it is an iframe</div>
<iframe id="myiframe" src="son.html" width="300px;" height="500px;"></iframe>
<div id="mm">if you see me through alert from an son's button,you win!</div>
<input type="button" id="btn" value="click me "/></body>
</html>

 子页面

View Code

<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
function(){
$(
"#btn").click(function(){
    
var mm = $('#mm', window.parent.document)
    alert(mm.html())    
})});
</script>
</head>
<body>
<input type="button" id="btn" value="click me "/>
<div>click the button above to get parent element's innerHTML</div>
<div id="smsg">if you see me in the alert msg,you win</div>
</body>
</html>