Skip to content

Instantly share code, notes, and snippets.

@dvygolov
Last active Jan 20, 2022
Embed
What would you like to do?
Защита страницы от скачивания: выключем контекстное меню, выделение и Ctrl+S
// Защита страницы - в <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