Translate

Wednesday, 31 December 2014

Disable Right Click of Page in c#

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Sample to Disable Right Click of Page</title>
<script language="JavaScript" type="text/javascript">
    //Message to display whenever right click on website
    var message = "Sorry, Right Click have been disabled.";
    function click(e) {
        if (document.all) {
            if (event.button == 2 || event.button == 3) {
                alert(message);
                return false;
            }
        }
        else {
            if (e.button == 2 || e.button == 3) {
                e.preventDefault();
                e.stopPropagation();
                alert(message);
                return false;
            }
        }
    }
    if (document.all) {
        document.onmousedown = click;
    }
    else {
        document.onclick = click;
    }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
from Suresh
-----

No comments:

Post a Comment