In JavaScript, there is a method window.getSelection()
, that lets me get the current selection that the user has made.
Is there a corresponding function
Maybe this will do it:
window.selection.clear();
Crossbrowser version:
if (window.getSelection) {
if (window.getSelection().empty) { // Chrome
window.getSelection().empty();
} else if (window.getSelection().removeAllRanges) { // Firefox
window.getSelection().removeAllRanges();
}
} else if (document.selection) { // IE?
document.selection.empty();
}