如何在父窗口调用子窗口的javascript方法? sub=window.open("","","");sub.functionname(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这样不行,因为你用var sub = window.open()后,这时用sub.methodname时,系统好像只会在window的javascript方法中找,然后报个错,说window没有这个method。让人很是郁闷! parent.htm:<html><head><script language=javascript>var newWin;function mm(){ newWin=window.open("child.htm","","width=200,height=150");}function nn(){ newWin.f1(); }</script></head><body><input type=button value="open" onclick="mm()"><input type=button value="调用2.htm中的函数f1" onclick="nn()"></body></html>child.htm:<html><head><script language=javascript>function f1(){ alert("这是2.htm中的alert!!"); }</script></head><body><input type=button value="Execute" onclick="f1()"></body></html> 谢谢关注。可是我突然发现是在appServer中,这种调用方式是会出现我说到的错误,可是如果不用server,是不会出这种错误的。to wssgwps(小刀会):你把这两个文件拷到例如tomcat的webapp中,用http://servername/../*.html的方式试一试就可以看出来了。期待大家的帮助。 <script>check=null;sub=null;function ifload(){try{sub.functionname();clearTimeout(check);window.status="done";}catch(e){window.status="waiting";}}sub=window.open("sub.htm","","");check=setTimeout(ifload,2000);</script> 我昨天也想到可能是因为窗口没有打开,因为如果在调用方法以前先alert一下,就可以调用成功。谢谢seabell(百合心)的解答,不过我认为你的check没有真正的是使用上,是不是应该把check=setTimeout(ifload,2000);放在一个while循环中?不过非常感谢你的帮助。 求个js定义变量 【菜鸟提问】这段代码怎么改才能让document.write的内容显示在当前页?? js做一些效果,发现了一些问题 关于ASP循环语句中DIV层ID重名,如何解决! 如何插入另一个js?在线等 求个JS效果,来个大神 请问怎样在状态栏显示网页的最后更新时间? 谁能帮我把这个帖子找回来啊? 谁有比较好看的树型目录的图标啊? execCommand 在己打开的窗口中怎样去掉菜单栏,工具栏等。 :( 。。高手帮忙把<br>动态的删除掉!
<html>
<head>
<script language=javascript>
var newWin;
function mm()
{
newWin=window.open("child.htm","","width=200,height=150");
}
function nn()
{
newWin.f1();
}
</script>
</head><body>
<input type=button value="open" onclick="mm()">
<input type=button value="调用2.htm中的函数f1" onclick="nn()">
</body>
</html>child.htm:
<html>
<head>
<script language=javascript>
function f1()
{
alert("这是2.htm中的alert!!");
}
</script>
</head>
<body>
<input type=button value="Execute" onclick="f1()">
</body>
</html>
to wssgwps(小刀会):
你把这两个文件拷到例如tomcat的webapp中,用http://servername/../*.html的方式试一试就可以看出来了。
期待大家的帮助。
check=null;
sub=null;
function ifload()
{
try
{sub.functionname();
clearTimeout(check);
window.status="done";
}
catch(e)
{
window.status="waiting";
}
}
sub=window.open("sub.htm","","");
check=setTimeout(ifload,2000);
</script>