Last active
March 2, 2017 05:44
-
-
Save wangpin34/d0359aa5546f81270745bbe9295d1acb to your computer and use it in GitHub Desktop.
Turn off these browser features which is not proper for your application like text selection, drag then open the file etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Disable text selection when double click or drag cursor | |
* @dom html element | |
*/ | |
function disableTextSelection(dom){ | |
if(dom.addEventListener){ | |
dom.addEventListener('mousedown', function(event){ | |
event.stopPropagation(); | |
event.preventDefault(); | |
}) | |
}else{ | |
dom.attach('onmousedown', function(){ | |
var event = window.event; | |
event.cancelBubble = true; | |
event.returnValue = false; | |
return false; | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment