父页面通过var win=window.open();打开一个窗口,可以通过win来操作子窗口,那么如果我打开多于一个子窗口,如何操作某个子窗口?

解决方案 »

  1.   

    win.document能得到子窗口的document对象吧
    那么你打开多个页面,就需要保存win这个东西,保存数组也好,保存变量也好。
      

  2.   

    var obj = new Object();
    var winA = window.open("a.html");//a窗口
    obj.a = winA;
    var winB = window.open("b.html");//b窗口
    obj.b = winB;obj.a.document.....//访问a窗口
    obj.b.document.....//访问b窗口
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>无标题页</title>
        <script type="text/javascript">
        var obj = new Object(); 
        function OpenWin()
        {
          var win=window.open("../Jquery/b.htm","b");
          obj.a=win;
          alert(obj.a.document.getElementById('bb').innerHTML);
        }
        </script>
    </head>
    <body>
        <input id="Button1" type="button" value="button" onclick="OpenWin();" />
    </body>
    </html>
    b页面
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>无标题页</title>
    </head>
    <body>
    <div id="bb">huguo</div>
    </body>
    </html>
      

  4.   

    如何保存打开窗口的引用,取决于你怎么操作打开的窗口var wins = {};
    function openPage(url){
      wins[url] || wins[url] = window.open(url);
      return wins[url];
    }这种也可以