如何判断鼠标是否选中网页中的文字?

如何判断鼠标是否选中网页中的文字,并且如何才能得到选中的文字?
---------------------------------------------------------------

abcdefg

1<input onclick='alert("有无选中 \? "+ (document.selection.createRange().text!=""))' type="button" value="判断有无文字选中"/>
1<input onclick='alert("网页里被选中的文字 : "+ document.selection.createRange().text)' type="button" value="得到选中的文字"/>
Published At
Categories with Web编程
comments powered by Disqus