Last active
September 27, 2024 08:36
-
-
Save dvygolov/dba868a513399ee0104ae3f8018a93e9 to your computer and use it in GitHub Desktop.
Защита страницы от скачивания: выключем контекстное меню, выделение и Ctrl+S
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
// Защита страницы - в <head> страницы пишем <script src="protect.js"></script> | |
window.onload = function(){ | |
document.body.oncontextmenu= function(){return false;}; | |
window.addEventListener('selectstart', function(e){ e.preventDefault(); }); | |
document.addEventListener('keydown',function(e) { | |
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) { | |
e.preventDefault(); | |
e.stopPropagation(); | |
} | |
},false); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment