[color=green]子页面调用父类JavaScript[/color]
1:window.top //最顶层窗口
2:window.self //当前窗口
3:window.parent //父级窗口
[color=green]iframe父页调用子页函数:[/color]
主页:
[color=red]父页面:[/color]t1.jsp
<iframe name=a1 id=iframe1 src="t2.asp"></iframe>
<input type=button value=button1 name=button1
onclick="a1.window.Test()">
[color=red]子页面[/color]t2.jsp:
<script>
function Test(){
alert("TEST");
}
</script>
1:window.top //最顶层窗口
2:window.self //当前窗口
3:window.parent //父级窗口
[color=green]iframe父页调用子页函数:[/color]
主页:
[color=red]父页面:[/color]t1.jsp
<iframe name=a1 id=iframe1 src="t2.asp"></iframe>
<input type=button value=button1 name=button1
onclick="a1.window.Test()">
[color=red]子页面[/color]t2.jsp:
<script>
function Test(){
alert("TEST");
}
</script>
本文介绍如何在网页中通过iframe实现子页面调用父页面的JavaScript函数,并展示了一个简单的示例,包括如何在父页面设置按钮来触发子页面中的函数。
4671

被折叠的 条评论
为什么被折叠?



