java script中如何访问其他窗口的变量那?

解决方案 »

  1.   

    页面自己打开的窗口可以访问
    parent top等
      

  2.   

    和调用函数类似
    <html>
    <head>
    <script   type="text/javascript">var parentstr="parent String"function callChild()
    {   alert(myFrame.window.childstr);
    }
    </script>
    </head><body>
    <input   type=button   value="调用child.html中的变量" onclick="callChild()">
    <iframe name="myFrame" src="child.html"></iframe>
    </body>
    </html><html>
    <head>
    <script type="text/javascript">
    var childstr="child String";
    function callParent() {
       alert(parent.parentstr);
       }
    </script>
    </head>
    <body>
    <input   type=button   value="调用parent.html中的变量"   onclick=callParent()>
    </body>
    </html>
      

  3.   

    现在页面之间的通信都是交给flash来做的...不只是支持二个页面,甚至二个不同浏览器打开的页面都能交换数据,调用函数, 你找下 flash的,LocalConnection类就行了