<input onfocus="this.select()">

解决方案 »

  1.   

    <script>
    function test()
    {
    if(event.srcElement.type=="text")
    event.srcElement.select()
    }
    document.onmousemove=document.onmouseclick=test
    </script>
    <input value="Test"><input value="Test"><input value="Test"><input type=checkbox value="Test">
      

  2.   

    可不可以不在text上作任何事情,只通过window或document的事件来处理?
      

  3.   

    onmousemove?那对于用键盘对focus做的切换呢?
    还有用代码对focus做的切换呢?
    有没有类似于onbeforeeditfocus的事件?
      

  4.   

    TAB切换实际上是 onfocus 事件
      

  5.   

    每个控件有个id,你用document.all("id")就可以控制了。
      

  6.   

    <input name=as value=sdfl>
    <input name=you value=sdfl>
    <input name=like value=sdfl>
    <input type=button value=set onclick=set(document.all("who").value)>
    选中的几个<input name=who>
    <script language=javascript>
    function set(i){
    try{
    var objs=document.all.tags("INPUT");
    objs[i-1].select();
    alert("第"+i+"被选中了吧")
    }catch(e){}
    }function window.onload(){
    set(1);//窗口初始化时,选中第一个
    }
    function document.onclick(){
    set(5);//单击窗口时,选中第四个
    }
    </script>
      

  7.   

    <input name=as value=sdfl onmouseover=this.select()>
    <input name=you value=sdfl onmouseover=this.select()>
    <input name=like value=sdfl onmouseover=this.select()>
      

  8.   

    我并不知道当前到达哪一个控件,
    只希望当控件获得焦点时,自动为选中状态,
    包括password,有没有写在window上的方法?