Thursday 16 May 2013

How to Disable Right click in the Browser




<script language=JavaScript>
<!-- http://ramsis-code.blogspot.in -->
var message="Right Click Function Disabled!";

function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false;")

</script>

<script type="text/javascript">
function showKeyCode(e){
var unicode=e.keyCode? e.keyCode : e.charCode
//alert(unicode)
// block F5
if(unicode == 116){
alert("Not Authorised.");
return false;
}

// block crtl+R
if(unicode == 82 && e.ctrlKey){
alert("Not Authorised.");
return false;
}
}
</script>


<body onload="JavaScript:document.body.focus();" onkeydown="return showKeyCode(event);">
</body>

No comments:

Post a Comment