Wednesday 27 February 2013

Disable F12 key in the 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 the hide 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:

Unknown said...

nice..........
really helpfull........

Ramesh R said...

What if the user select "INSPECT ELEMENT" or "CTRL+U".....

Unknown said...

Oh... this script doesn't proper work...
first press f10 after f12

Unknown said...
This comment has been removed by the author.
word 2020 Defence News said...

not work bakwas chil mat post kiya kro

Post a Comment