在java script中能不能访问其他窗口定义的方法? 在java script中能不能访问其他窗口定义的方法? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 只要窗口之间有关系就可以。对于用win = window.open()打开的窗口:父窗口访问子窗口的方法 win.xx();子窗口访问父窗口的方法 opener.xx();对于iframe父窗口访问子窗口的方法 document.getElementById("iframe_id").contentWindow.xx(); 或iframe_name.xx();子窗口访问父窗口的方法 parent.xx();对于 framesetframe之间 top.frame_name.xx();父窗口访问frame的方法 frame_name.xx();frame访问父窗口的方法 top.xx(); 可以的,在不跨域的情况下,楼上说的都可以补充一种 :showModalDialog() 弹出模态窗,调用方法也类似<html> <head> <script type="text/javascript"> function say() { alert("parent.html------>I'm at parent.html"); } function callChild() { //document.frames("myFrame").f1(); myFrame.window.say(); } </script> </head> <body> <input type=button value="调用child.html中的函数say()" onclick="callChild()"> <iframe name="myFrame" src="child.html"></iframe> </body> </html> <html> <head> <script type="text/javascript"> function say() { alert("child.html--->I'm at child.html"); } function callParent() { parent.say(); } </script> </head> <body> <input type=button value="调用parent.html中的say()函数" onclick="callParent()"> </body> </html> 使用javascript转换二进制和汉字 链接 请问web程序如何与桌面程序进行交互? 如何解决bootstrap与ie不兼容问题。 急求正则 opener 的用法,都用在那些场合? 关于网页内容动态改变的问题,请进来看看! 请帮忙,在线等:如何用javasript实现点击表格列替换图片?? 简单问题:打开网页时动态加入表格,我这样为什么不行?先谢了! 关于form.elements aspx网页,如何弹出新窗口显示报错信息? JavaScript如何实现HTTP BASIC认证
对于用win = window.open()打开的窗口:
父窗口访问子窗口的方法 win.xx();
子窗口访问父窗口的方法 opener.xx();对于iframe
父窗口访问子窗口的方法 document.getElementById("iframe_id").contentWindow.xx(); 或iframe_name.xx();
子窗口访问父窗口的方法 parent.xx();对于 frameset
frame之间 top.frame_name.xx();
父窗口访问frame的方法 frame_name.xx();
frame访问父窗口的方法 top.xx();
<html>
<head>
<script type="text/javascript"> function say() {
alert("parent.html------>I'm at parent.html");
} function callChild()
{
//document.frames("myFrame").f1();
myFrame.window.say();
}
</script>
</head>
<body>
<input type=button value="调用child.html中的函数say()" onclick="callChild()">
<iframe name="myFrame" src="child.html"></iframe>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function say()
{
alert("child.html--->I'm at child.html");
} function callParent() {
parent.say();
}
</script>
</head>
<body>
<input type=button value="调用parent.html中的say()函数" onclick="callParent()">
</body>
</html>