Skip to content

Instantly share code, notes, and snippets.

@Illusionist3886
Last active April 23, 2018 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Illusionist3886/29014ad775cb989822397f05dbb24be4 to your computer and use it in GitHub Desktop.
Save Illusionist3886/29014ad775cb989822397f05dbb24be4 to your computer and use it in GitHub Desktop.
Disable Right Click and Ctrl+U
<html lang="en" oncontextmenu="return false" onselectstart="return false" ondragstart="return false">
<body>
<!-- Your Code Goes Here -->
<script>
document.onkeydown = function(e) {
if (e.ctrlKey &&
(e.keyCode === 67 ||
e.keyCode === 86 ||
e.keyCode === 85 ||
e.keyCode === 117)) {
alert('You are not allowed to perform this action.');
return false;
} else {
return true;
}
};
</script>
<script src="yourpath/jquery.js"></script>
<script>
$(document).bind('keydown', function(e) {
if(e.ctrlKey && (e.which == 83)) {
e.preventDefault();
alert('You cannot save this page');
return false;
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment