I am working on a drag-and-drop image viewer. When the user drags the scroll bar, part of the text on the web page is selected. I tried
window.getSelection().removeAllRanges();
but this does not seem to work in IE7 / 8. Also tried
document.getSelection().removeAllRanges();
which seems to work just as well as with IE7 / 8.
Are there any other ways to do this? I don't know any jQuery solutions, but if there is, let me know (:
EDIT: This is the onmouse-event context
$("#slideBar").mousedown(function(f) { mouseDown = true; some more code... } $(document).mouseup(function() { if (mouseDown) { window.getSelection().removeAllRanges(); more code... } }
source share