AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Monday, 18 April 2016

How to Prevent the F12 key and Right mouse button click?

In this article I will discuss How to Prevent the F12 key and Right mouse button click? F12 key is used to open debugger in a web page. Please follow below steps to disable debugging option & right click.
Step 1- Add jquery reference in your code.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

Step 2- Add following script to prevent F12 key click & right click.
<script>
$(document).keydown(function (event) {
if (event.keyCode == 123) {
return false;
}
else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
return false;
}
});

$(document).on("contextmenu", function (e) {
e.preventDefault();
});
</script>

key code of F12 key is 123. After using above code you found that F12 key is disabled on a webpage.

0 comments :

Post a comment

  • Popular Posts
  • Comments