In this article I will explain How to disable the F12
key with mouse right click operations in Web site running in the browser? Using Jquery
As a Developer you can see the code in development
time it’s OK for you, but when others are trying to see your application code
and do some operations definitely we don't want to disclose this. So what
is the solution? We can easily prevent this using some simple JavaScript and jQuery scripts.
Clients (or) Users will not be accessing the F12 key
with mouse right click options.
Below is JQuery code for disable F12 Key
and Mouse Right click Options
<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>
Total
code for disable F12 Key and Mouse right click options:
html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>F12 Key And
Mouse disable options</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
F12 Key And Mouse disable options:
<div id="status"></div>
<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>
</body>
</html>
No comments:
Post a Comment