日期:2014-05-16  浏览次数:20343 次

js得到选中的文字
  <script type="text/javascript">
    function getWords(){  
    var text;  
    if(navigator.appName=="Microsoft Internet Explorer"){  
       text=document.selection.createRange().text;  
    }else{  
        text=window.getSelection();  
  }  
    alert(text);
}  
   
    </script>
  </head>
 
  <body>
  <input type="button" value="获取" onclick="getWords()"/>
<br/>  
<textarea rows="15" id="txt" cols="100"></textarea>  
</body>  
</html>