Disable right click, Inspect Element and page source using JavaScript in Html and asp.net

This is a code to hide right click on any web page and to hide inspect element and page source of page. I have used JavaScript to hide a source code below is the code.

It blocks Ctrl + U, Right click, F12, and Ctrl+ Shift + J

Step One :  copy JavaScript and paste under head tag.

<script>
document.onkeydown = function(e) {
if(event.keyCode == 123) {
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){
return false;
}
}
</script>

Step Two :  Put this code  in the body tag.

<body oncontextmenu="return false;">

Now you can run your page and check using all the short controls and right click all are disabled now…
Happy Coding Day


Comments

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. wait i'll give you another code or any other solutions...

      Delete
    2. This comment has been removed by the author.

      Delete
    3. This js only working on chrome not other browsers.

      Delete
  2. this is not working on mouse right click event

    https://dwarkeshtech.com/

    ReplyDelete

Post a Comment

Popular posts from this blog

Create Login With Role Using Thee Tire Architecture In Asp.Net C#