你的a和b必须有一定的联系
比如a是通过在b上window.open打开的

解决方案 »

  1.   

    对,两个窗口要有关系才行,一般是用window.open或框架来实现这个功能的...
      

  2.   

    在b.htm中写window.open('a.htm','','width:300;height:300');
    b.htm中有个input框的id为txt在a.htm的button的onclick里写alert(opener.txt.value)
      

  3.   

    ---------a.htm--------------------
    <HTML>
    <HEAD>
    <TITLE>a.htm</TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <script language="JavaScript">
    var subWin = window.open('b.htm');
    </script>
    </HEAD>
    <BODY>
    <input type="button" value="查看" onclick="if(subWin && !subWin.closed)alert(subWin.document.all.txt.value);">
    </BODY>
    </HTML>
    ---------------------------------------------------b.htm--------------------
    <HTML>
    <HEAD>
    <TITLE>b.htm</TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    </HEAD>
    <BODY>
    <input type="text" id="txt">
    </BODY>
    </HTML>
    ---------------------------------