Here are few JavaScript code snippets that can be useful on your web pages if you want to diasable right click on your page or on a particular div. You can also disable text selection on your page. Just have a look.
Source:http://amiteighty82.blogspot.com/2011/01/disabling-right-click-on-web-page_19.html
Disabling right click on web page:
Just paste the code snippets in your Head tag
<script LANGUAGE="JavaScript">
document.oncontextmenu=new Function ("return false");
</script>
Disabling right click on a particular div:
<script LANGUAGE="JavaScript">
document.getElementById('div1').oncontextmenu=new Function ("return false")
</script
Disabling Text copy and right clicks:
<script language="JavaScript">
<!-- Disable
function disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
document.oncontextmenu=new Function ("return false")
//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
//-->
Thanks for providing this useful script.
awesome
thanks! 🙂
Thanks and this script is very useful…
Thansks man you save my life