当前位置: 代码迷 >> JavaScript >> js获取网页下选中的文字
  详细解决方案

js获取网页下选中的文字

热度:63   发布时间:2012-10-07 17:28:51.0
js获取网页上选中的文字
<script language="javascript">

    function getSelectText(){
        if(document.selection){
            return document.selection.createRange().text;// for IE
        }else{
            return document.getSelection(); // for firefox
        }
    }

</script>

<body onmouseup="alert(getSelectText())">
拖动鼠标选择文字
</body>
  相关解决方案