javascript - Prevent text selection on mouse drag -


how can prevent text selection without using traditional method e.stoppropagation (related question @ bottom)?
there call can make "unhighlight whatever highlighted"?

i bound mouse events on document because there hundred [more or less] elements in page want have interact each other.

the reason don't bind events elements instead because when mouse moves off element, mouse events stop triggering. need bind document correctly watch mouse events.

the problem using method traditional method (link below) time listener triggered, elements text has evaluated mouse event.

my code works fine chrome. issues below applies firefox.

related question: how can prevent text/element selection cursor drag
talks preventing bubbling text element with:

if(e.stoppropagation) e.stoppropagation(); if(e.preventdefault) e.preventdefault(); e.cancelbubble=true; e.returnvalue=false; return false; 

apologies deleting last answer realized still wouldn't work in ff.

i believe answer, along css answer above, produce result you're looking for. here solution works cross-browser.

var unfocus = function () {   if (document.selection) {     document.selection.empty()   } else {     window.getselection().removeallranges()   } }  

called onmouseup , onmousemove trick.

here's fiddle: http://jsfiddle.net/z2kpcwb6/