Chinaunix首页 | 论坛 | 博客
  • 博客访问: 458455
  • 博文数量: 226
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2111
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-20 09:02
个人简介

web web web

文章分类

全部博文(226)

文章存档

2020年(2)

2019年(1)

2018年(3)

2017年(26)

2016年(57)

2015年(60)

2014年(77)

我的朋友

分类: Web开发

2015-09-01 16:41:51

父页面:
    调用子页面的值:iframeName.window.document.getElementById("子页面元素ID").value
html:
<body>
    <input id="button" type="button" value="调用child.html中的函数say()" onclick="callChild()"/>
    <iframe name="myFrame" src="child.html"></iframe>
</body>

js:
<script type="text/javascript">
function say(){
    alert("parent.html");
}
function callChild(){
    myFrame.window.say();
    myFrame.window.document.getElementById("button2").value="调用结束";
}
</script>

子页面:
    调用父页面的值:parent.window.document.getElementById("父页面的元素ID").value
html:
<body>
    <input id="button" type="button" value="调用parent.html中的say()函数" onclick="callParent()"/>
</body>
js:
<script type="text/javascript">
function say(){
    alert("child.html");
}
function callParent(){
    parent.say();
    parent.window.document.getElementById("button1").value="调用结束";
}
</script>


阅读(1685) | 评论(0) | 转发(0) |
0

上一篇:Java教程

下一篇:解决点击与双击冲突

给主人留下些什么吧!~~