Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function disableSelection(target){
- if (typeof target.onselectstart!="undefined")
- target.onselectstart=function(){return false}
- else if (typeof target.style.MozUserSelect!="undefined")
- target.style.MozUserSelect="none"
- else
- target.onmousedown=function(){return false}
- target.style.cursor = "default"
- }
- //Sample usages
- //disableSelection(document.body)
- //disableSelection(document.getElementById("mydiv"))
- </script>
- <script type="text/javascript">
- disableSelection(document.body)
- </script>
- Some informations of script :
- //disableSelection(document.body) = Disable text selecting on the entire body
- //disableSelection(document.getElementById("mydiv")) = Disable text selection on element with id="mydiv"
- disableSelection(document.body) = Disable text selecting on the entire body of page(s)
Advertisement
Add Comment
Please, Sign In to add comment