We can disable right click on apage using the following code
<script type="text/javascript">
document.onmousedown = clickfn;
function clickfn(e) {
var button;
if (navigator.appName == "Microsoft Internet Explorer") {
button = event.button;
}
else {
button = e.buttons;
}
if (button == 2) {
alert("Right Click Disabled");
if (navigator.appName == "Microsoft Internet Explorer") {
event.returnValue = false;
}
return false;
}
}
</script>
navigator.appName == "Microsoft Internet Explorer" this is used because in ie 7 "e" is not supported so we used event in common for all ie versions...
<script type="text/javascript">
document.onmousedown = clickfn;
function clickfn(e) {
var button;
if (navigator.appName == "Microsoft Internet Explorer") {
button = event.button;
}
else {
button = e.buttons;
}
if (button == 2) {
alert("Right Click Disabled");
if (navigator.appName == "Microsoft Internet Explorer") {
event.returnValue = false;
}
return false;
}
}
</script>
navigator.appName == "Microsoft Internet Explorer" this is used because in ie 7 "e" is not supported so we used event in common for all ie versions...
nice share gan, sekedar tambahan untuk chrome perlu ngehandle even document.oncontextmenu juga, klo ndak gitu menu klik kanan nya masih keluar..
ReplyDeletebagaimana cara handle document.oncontextmenu nya..?
Deleteboleh minta contoh codes nya..?