How to disable F12 key in Browser?

When user press F12 key, browsers developer tool bar will open in the below portion of the browser. By
using the developer tool bar user can see the design, javascript code and corresponding css applied to the controls in the page. To prevent the user to do that we will hide the developer tool bar.

You can use the below code to do that. 

Write the below code in the head section of the page.

<script type="text/javascript">

document.onkeydown = function (event)
{
     event = (event || window.event);
     if (event.keyCode == 123 || event.keyCode == 18)
     {
           alert("This function is disabled here");
           return false;
     }
}
</script>

5 comments:

  1. Thank you. It really helps me.

    Satish.

    ReplyDelete
  2. small , enough, and great article ever!

    ReplyDelete
  3. it is not enough for security, user can enter into developer mode using - Browser Menu->Tools->Developer Tools.

    ReplyDelete
  4. Yes, agreed. But it is just a small hack.

    ReplyDelete

We are here to listen you, Comment your valueable opinion...!!!