Created
November 1, 2011 09:18
-
-
Save ifree/1330206 to your computer and use it in GitHub Desktop.
getselection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetSel() | |
{ | |
if (window.getSelection) return window.getSelection(); | |
else if (document.getSelection) return document.getSelection(); | |
else if (document.selection) return document.selection.createRange().text; | |
else return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
火狐下 window.getSelection() 返回的是一个对象哦,toString() 下或者用 document.getSelection() 才能得到字符串的。