title: remove selection using javascript
body: <p>I'm working on a image viewer that has a draggable scrollbar. When the user drags the scrollbar, some of the text on the webpage becomes selected. I've tried</p>
  
  <pre><code>window.getSelection().removeAllRanges();
  </code></pre>
  
  <p>but that doesn't seem to work in IE7/8. Also tried the</p>
  
  <pre><code>document.getSelection().removeAllRanges();
  </code></pre>
  
  <p>which seems to work just as "well" with IE7/8.</p>
  
  <p>Are there any other ways of doing this? Don't know of any jQuery solutions, but if there are, let me know (:</p>
  
  <p><strong>EDIT:</strong> This is the context of the onmouse-event</p>
  
  <pre><code>$("#slideBar").mousedown(function(f) {
      mouseDown = true;
      some more code...
  }
  
  $(document).mouseup(function() {
      if (mouseDown) {
         window.getSelection().removeAllRanges();
         more code...
      }
  }
  </code></pre>