Feeds:
Posts
Comments

Archive for the ‘JavaScript’ Category

Hi All. This is my first post on this blog and I am feeling very happy while publishing it. This post is on javascript.

This post will show how you can DISABLE right click on your web page. It can be used for security purpose or controlling the right click context menus.

Here goes the java script code for it.

<script>

var isNS = (navigator.appName == “Netscape”) ? 1 : 0;
if(navigator.appName == “Netscape”) document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;

</script>

Thanks & Regards,

Gaurav Rana

Read Full Post »

Design a site like this with WordPress.com
Get started