Friday, 17 August 2012

Disabling Rightclick on webpage using javascript


JAVA SCRIPT CODE :


var message = "Right click testing";
        function click(e) {
            if (document.all) {
                if (event.button == 2) {
                    alert(message);
                    return false;
                }
            }
            if (document.layers) {
                if (e.which == 3) {
                    alert(message);
                    return false;
                }
            }
        }
        if (document.layers) {
            document.captureEvents(Event.MOUSEDOWN);
        }
        document.onmousedown = click;




ASPX CODE

Put above code between <Head></Head> tag

And Run the script !!

On web , try to right click and wait for alert message !!

No comments:

Post a Comment