Skip to content

Instantly share code, notes, and snippets.

@rainyjune
Created February 14, 2013 02:15
Show Gist options
  • Save rainyjune/4950141 to your computer and use it in GitHub Desktop.
Save rainyjune/4950141 to your computer and use it in GitHub Desktop.
Querying Selected Text
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