Skip to content

Instantly share code, notes, and snippets.

@jpbyrne
Created November 15, 2012 16:02
Show Gist options
  • Save jpbyrne/4079390 to your computer and use it in GitHub Desktop.
Save jpbyrne/4079390 to your computer and use it in GitHub Desktop.
This method is used to prevent the selection of HTML page elements.
function disableSelection(target){
if (typeof target.onselectstart!="undefined") // if IE
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") // if Firefox
target.style.MozUserSelect="none";
else // others
target.onmousedown=function(){return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment