用HTC实现吧,要求IE5.0以上,Netscape就不行了,代码如下:----test.htm---------------------------------------
<style>
input {behavior:url(p.htc)}
</style><input type=text name=txt1 value="111">
<BR>
<input type=text name=txt2 value="222">
-----------------------------------------------------p.htc--------------------------------------------
<PUBLIC:ATTACH EVENT="onselectstart" ONEVENT="doselect()"/><script language="JavaScript">
function doselect(){
  element.value = element.value;
}
</script>
---------------------------------------------------
关键点
事件:EVENT="onselectstart"
实现:element.value = element.value;

解决方案 »

  1.   

    嗯,这个回答基本可以实现了。牛!,,牛呀。还有一个小小的问题,如果有个这样的->
    <input type='text' onfocus="this.select();">
    也将不会被选择,是吧?
      

  2.   

    <input type='text' onfocus="this.select();">
    定义onfocus="return false;"
    不就不选中了?
      

  3.   

    是的不会被蓝底选定,这里的onfocus其实也发生了,只不过onselectstart事件紧跟其后发生,故淹掉了"this.select()"效果,做个测试就一目了然了:
    ----test.htm---------------------------------------
    <style>
    input {behavior:url(p.htc)}
    </style><input type=text name=txt1 value="111" onfocus="alert('1-1');this.select();">
    <BR>
    <input type=text name=txt2 value="222" onfocus="alert('1-2');this.select();">
    -----------------------------------------------------p.htc--------------------------------------------
    <PUBLIC:ATTACH EVENT="onselectstart" ONEVENT="doselect()"/><script language="JavaScript">
    function doselect(){
      alert("2");
      element.value = element.value;
    }
    </script>
    ---------------------------------------------
      

  4.   

    黑翼,不是这样的。
    原来的代码有onfocus时全选的,有onfocus时不全选的,用的是onfocus="this.select();",
    上面高人说了以后,tab时候就都不全选了。,,,没有onfocus="this.select();"的满足了我的要求,但是原来代码中要求全选的,这回也不能选中了。我要的是选中,不是return false....
      

  5.   

    taxmma(好客007) 我有点佩服你了。你说的都是正解,呵呵
    那么,这个东西能改善吗?
      

  6.   

    其实很简单的,给element加个属性就可以了,也不用需要全选时加"onfocus="this.select();""
    如下:
    ------test.htm---------------------------------------
    <style>
    input {behavior:url("p.htc")}
    </style>
    <input type='text' value="111"><br>
    <input type='text' value="222"><br>
    <input type='text' value="333" selAll><br>
    -----------------------------------------------------
    -----p.htc-------------------------------------------
    <PUBLIC:ATTACH EVENT="onselectstart" ONEVENT="doselect()"/><script language="JavaScript">
    function doselect(){
      if(element.selAll==undefined)
        element.value = element.value;
      else
        element.select();
    }
    </script>
    ---------------------------------------------
    看看是不是达到要求了。
      

  7.   

    很好很好很好,,,非常感谢,,,,这个问题,,就算是解决了。,,,不管Netscape了