How to block text selection without input textarea and select items i actually have the script that works in IE but not in other browsers, here it is:
var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
document.onmousedown=click;
function click()
{
if ((event.button==2) || (event.button==3)) { alert("Yazı Kopyalayamazsınız!");}
}
i need to work it the same way in other browsers, there must be a ready script, just couldnt find in net..
Updated my answer to be more clear:
browsers can disable selecting using css styles or using special element attribute. This way is better:
Opera and IE ignores such a style, but there is html element attribute unselectable, which denies selecting. Try the following page (I tested in IE8, FF3.6, Safari5, opera11, Chrome8):
For additional information about it visit this page. Now you can pick best option for you to use/mantain. One more time - this solution does not need javascript at all and should be imho more safe (if you can edit html\css pages and don't need dynamic. otherwise you can try to add css class\element attribute through javascript..)
onmousedown disables the selection for Firefox, Safari, Opera, Chrome and most other web browsers, onselectstart for IE.
Though disabling text selection and context menus is very bad style and does not prevent the pro-users from selecting your text. Simply disabling JavaScript in their browsers enables the selection again.