Search code examples
javascripthighlighting

javascript - stop browser highlighting images


I have made a script that allows users to drag images around. Unfortunatly though most browsers higlight the image blue. Is there a way to disable this behaviour in all browsers?


Solution

  • Return false from your mousedown/mousemove handler to prevent default browser actions (default action is the select the underlying element on mousedrag).

    EDIT

    What I meant was this:

    document.onmousemove = function() {
        // Do your stuff
    
        return false;
    }
    

    You might have different looking functions, but in the end, put return false.