Home > Code > Jquery > How to disable Right Click on the page using JQuery?

How to disable Right Click on the page using JQuery?

by Thamil   on Jan 03, 2013   Category: Jquery   |  Views: 957    |  Points: 25   |  Gold 



Below is the sample JQuery code snippet to disable right clicks on the page and prevent to viewing the source code or saving images from the page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="WebApplication1.test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Disable Right Click using JQuery</title>
<script type="text/javascript" src="Javascript/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
alert('Right click disabled'); return false;
});
});
</script>

</head>
<body>
<form id="form1" runat="server">
<div> Test - Disable Right Click using JQuery
</div>
</form>
</body>
</html>





Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts