Skip to content

Instantly share code, notes, and snippets.

@jgv
Created June 29, 2010 17:59
Show Gist options
  • Save jgv/457558 to your computer and use it in GitHub Desktop.
Save jgv/457558 to your computer and use it in GitHub Desktop.
function getSelText() {
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().text;
}
else return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment