Disable right click on web page using javascript



This tutorial will go over how to DisableRight Mouse Click using javascript

<!-- turn off right click -->

<script language=javascript>
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
</script>

Note:- This only stops people from right clicking on your page and there is no real way to stop people from viewing your html, if someone is determined to see your code they will.

2 comments :

  1. Worked perfectly! Thank you very much! I will bookmark this page for future reference!
    website design

    ReplyDelete