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 !!

Comments

Popular posts from this blog

Add Serial no in crystal report without coding

File operations in C# (.net)

SQL – Generate decimal numbers sequence for particular number range