Last active
February 12, 2024 05:53
-
-
Save jack2jm/5b54ef1dcc7c60ecbd51e86607cfb663 to your computer and use it in GitHub Desktop.
This gist can help you to prevent from view page source using ctrl + u. also this helps you to disable right click.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| // To To Disable ctrl+c, ctrl+u | |
| jQuery(document).ready(function($){ | |
| document.oncontextmenu = document.body.oncontextmenu = function() {return false;} | |
| $(document).keydown(function(event) { | |
| var pressedKey = String.fromCharCode(event.keyCode).toLowerCase(); | |
| console.log(pressedKey); | |
| // i, c, j -> open inspect element view | |
| // ctr + u or c -> pag src | |
| // f12 - 123 | |
| if ( event.which === 123 || (event.ctrlKey && (pressedKey == "c" || pressedKey == "u")) || (event.ctrlKey && event.shiftKey && (pressedKey == "i" || pressedKey == "c" || pressedKey == "j") ) ) { | |
| //alert('Sorry, This Functionality Has Been Disabled!'); | |
| //disable key press porcessing | |
| return false; | |
| } | |
| }); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment