就是你一点这个input,该text中的文字全部被选中,背景变蓝,右键直接复制能把text里的文字都复制下来?
效果类似你点IE的地址栏的效果,多谢~~~~

解决方案 »

  1.   

    <input type="text" value="dddsf" onclick="this.select();"/>
      

  2.   

    input 添加onclick事件 onclick=this.select()
    可以在单击的时候选中.可是距离地址栏的效果还有差距.需要别的处理
      

  3.   


    <html><head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script>
    function $(id){return document.getElementById(id)}function test(o,n,e){
      if(n==0){
        o.select();
        o.style.backgroundColor='#0000FF';
        o.style.color='#FFFFFF';
      }
      else{
        e=e||window.event;
        if (e.button==2){
          var s=clipboardData.setData("Text",o.value);alert("已经复制了文本框内容:"+o.value)
        }
      }
    }
    </script>
    </head>
    <body>
    <input type=text id='a' value='' onclick="test(this,0)" onmousedown='test(this,1,event)' />
    一点这个input,该text中的文字全部被选中,背景变蓝,右键直接复制能把text里的文字都复制下来
    </body></html>