Created
February 14, 2013 02:15
-
-
Save rainyjune/4950141 to your computer and use it in GitHub Desktop.
Querying Selected Text
This file contains hidden or 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 getSelectedText() { | |
if (window.getSelection) // The HTML5 standard API | |
return window.getSelection().toString(); | |
else if (document.selection) // This is the IE-specific technique. | |
return document.selection.createRange().text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment