我正在开发一个带有可拖动滚动条的图像查看器。当用户拖动滚动条时,网页上的一些文本会被选中。我已经尝试过
window.getSelection().removeAllRanges();
但在IE7/8中似乎不起作用。也尝试了
document.getSelection().removeAllRanges();
这种方法在IE7/8中似乎也能“很好地”工作。
还有其他的方法吗?不知道是否有jQuery解决方案,如果有,请告诉我(:
编辑:这是onmouse事件的上下文。
$("#slideBar").mousedown(function(f) {
mouseDown = true;
some more code...
}
$(document).mouseup(function() {
if (mouseDown) {
window.getSelection().removeAllRanges();
more code...
}
}