function RemoveSelection () {
if (window.getSelection) { // all browsers, except IE before version 9
var selection = window.getSelection ();
selection.deleteFromDocument ();
/* The deleteFromDocument does not work in Opera.
Work around this bug.*/
if (!selection.isCollapsed) {
var selRange = selection.getRangeAt (0);
selRange.deleteContents ();
}
// The deleteFromDocument works in IE,
// but a part of the new content becomes selected
// prevent the selection
if (selection.anchorNode) {
selection.collapse (selection.anchorNode, selection.anchorOffset);
}
}
else {
if (document.selection) { // Internet Explorer
document.selection.clear ();
}
}
}
function EmptySelection(){
if(document.selection){
document.selection.empty();
}else{
var selection = document.getSelection();
selection.removeAllRanges();
}
}