Skip to content

Instantly share code, notes, and snippets.

@wangpin34
Last active March 2, 2017 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangpin34/d0359aa5546f81270745bbe9295d1acb to your computer and use it in GitHub Desktop.
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.
/*
* 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