<script lanaguage=javascript>
function keyUp(content, evt)
{
if(content.value.length > 9) content.value = content.value.substr(0, 9); 
    if(evt.keyCode == 13)
    {
       alert(content.value);            
       hide();
       setTimeout("show()",3000);  
    }       
}
function show(){
text.readonly = false;
}
function hide(){
text.readonly = true;
}
</script>
<textarea id="text" ROWS="5" COLS="50" onkeypress="keyUp(this,event)"></textarea>

解决方案 »

  1.   

    <html>
    <head></head>
    <script language="JavaScript">
    function getTxt()
    {
      var txt=document.selection.createRange().text;
      alert(txt);
    }
    </script>
    <body >
        
    <input type="text" id="text1">
    <br/>
    <input type='button' value='getTxt' onclick='getTxt()'/>
    </body>
    </html>
      

  2.   

    呵呵 ,谁叫你不比多写些html代码呢现在的人提问都想直接就运行起来的 ,世风日下啊 而恰恰有了showbo这样的热心人