<script language="javascript">//<!--
function c(){
var s=document.getElementById('show');
var e=window.document.activeElement;
s.innerText="当前活动控件:"+e.tagName+" id="+e.id+" name="+e.name;
}
window.setInterval("c()",1);
//--></script>
<div style="width:200px;height:50px;border:solid 1px black;" id="show"></div>
t1:inp1 <input type="text" id="t1" name="inp1" />
t2:inp2 <input type="text" id="t2" name="inp2" />
<button id="b1" name="btn1">b1:btn1</button>

解决方案 »

  1.   

    1.如何获得此控件的Name或ID 
      document.activeElement(当前页面)
    2.2个毫无关联的页面实现起来就不好办了~
      

  2.   

    main.html:
    ====================
    <body onload="window.open('a.htm','','width=200,height=100');window.open('b.htm','','width=200,height=100')"  > 
    <input type=hidden id=temp value="">
    </body>===================
    a.htm:
    ===================
    <script language="javascript">
    <!--
    function setVal(val){
     opener.document.getElementById("temp").value=val
     } 
    //-->
    </script>
    <body> 
     <table>
    <tr>
    <td> 
    <input type=button value="aaaaaa"  onclick="setVal(this.value)">
    </td>
    </tr>
    <tr>
    <td> 
    <input type=button value="bbbbbb"  onclick="setVal(this.value)">
    </td>
    </tr>
    <tr>
    <td> 
    <input type=button value="cccccc"  onclick="setVal(this.value)">
    </td>
    </tr>
    </table> 
    </body>================
    b.htm:
    ================
    <script language="javascript">
    <!--
    function getVal(){
      window.document.activeElement.value=opener.document.getElementById("temp").value;
    }
    window.setInterval("getVal()",1);
    //-->
    </script>
    <body onload="document.getElementById('t1').focus()">
    <input type=text>
    <input type=text id=t1>
    <input type=text>
    </body>
    ======================
    a.htm和b.htm都是main.html的弹出窗口
      

  3.   

    没关联的页面,你可以直接传参数,
    再用PHP或ASP产生一段JS,去控制你想得到的焦点。
      

  4.   

    同意楼上的,用php或asp等生成js
      

  5.   

    既然是弹出窗口,都可以在主窗口中进行操纵的,也就是在主窗口中加入document.activeElement进行判断即可