focus不到,或者说看不到效果,只好select:<input type="text" id="t" readonly="readonly" /><script>
document.getElementById("t").value = "hello";
document.getElementById("t").select();
</script>

解决方案 »

  1.   

    为什么要获取焦点
    onclick事件不行吗?
      

  2.   

    <input onkeydown="return false">
      

  3.   

    <body>
    <input type="text" id="txt" maxlength="0" readonly onfocus="alert()">
    <script type="text/javascript">
    <!--
    txt.value = "asdfasdf";
    //-->
    </script></body>
      

  4.   

    能说明一下你想做什么吗?
    通过语句赋值就不需要给焦点了,找到ID或Name不就可以了吗?