Disable selection on Browser using JS

Sharing is caring!

1.Disable selection on Browser using JS


    

window.onload= function()  
{
disableSelection(document.body)
}
functiondisableSelection(target){
if (typeof target.onselectstart!=“undefined”) //IE
        target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!=“undefined”)//Firefox
        target.style.MozUserSelect=“none”
else //All other ie: Opera
        target.onmousedown=function(){return false}
target.style.cursor = “default”
}


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.