sub=window.open("","","");
sub.functionname();

解决方案 »

  1.   

    这样不行,因为你用var sub = window.open()后,这时用sub.methodname时,系统好像只会在window的javascript方法中找,然后报个错,说window没有这个method。让人很是郁闷!
      

  2.   

    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>
      

  3.   

    谢谢关注。可是我突然发现是在appServer中,这种调用方式是会出现我说到的错误,可是如果不用server,是不会出这种错误的。
    to wssgwps(小刀会):
    你把这两个文件拷到例如tomcat的webapp中,用http://servername/../*.html的方式试一试就可以看出来了。
    期待大家的帮助。
      

  4.   

    <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>
      

  5.   

    我昨天也想到可能是因为窗口没有打开,因为如果在调用方法以前先alert一下,就可以调用成功。谢谢seabell(百合心)的解答,不过我认为你的check没有真正的是使用上,是不是应该把check=setTimeout(ifload,2000);放在一个while循环中?不过非常感谢你的帮助。