Created
March 21, 2011 23:09
-
-
Save jookyboi/880434 to your computer and use it in GitHub Desktop.
Disable click-and-drag selection in all browsers through css and javascript
This file contains hidden or 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
for IE: | |
function disableSelection(target){ | |
if (typeof target.onselectstart!="undefined") //IE route | |
target.onselectstart=function(){return false} | |
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route | |
target.style.MozUserSelect="none" | |
else //All other route (ie: Opera) | |
target.onmousedown=function(){return false} | |
target.style.cursor = "default" | |
} | |
for others: | |
-moz-user-select: -moz-none; | |
-khtml-user-select: none; | |
-webkit-user-select: none; | |
-o-user-select: none; | |
user-select: none; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment