js获取鼠标划词

<script type="text/javascript">
function getSelectText()
{
    var txt = null;
    if (window.getSelection){  // mozilla FF
        txt = window.getSelection();
    }else if (document.getSelection){
        txt = document.getSelection();
    }else if (document.selection){  //IE
        txt = document.selection.createRange().text;
    }
    return txt;
}
</script>

你可能感兴趣的:(IE)