Skip to content

Instantly share code, notes, and snippets.

@ifree
Created November 1, 2011 09:18
Show Gist options
  • Save ifree/1330206 to your computer and use it in GitHub Desktop.
Save ifree/1330206 to your computer and use it in GitHub Desktop.
getselection
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 '';
}
@ifree
Copy link
Author

ifree commented Nov 1, 2011

就是一个对象,字符串相加就是调的toString

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment