Skip to content

Instantly share code, notes, and snippets.

@dvygolov
Last active September 27, 2024 08:36

Revisions

  1. dvygolov revised this gist Jul 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion protect.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    // Защита страницы - в <head> страницы пишем <script src="protect.j"></script>
    // Защита страницы - в <head> страницы пишем <script src="protect.js"></script>
    window.onload = function(){
    document.body.oncontextmenu= function(){return false;};
    window.addEventListener('selectstart', function(e){ e.preventDefault(); });
  2. dvygolov created this gist Feb 14, 2020.
    12 changes: 12 additions & 0 deletions protect.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    // Защита страницы - в <head> страницы пишем <script src="protect.j"></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);
    }