代码之家  ›  专栏  ›  技术社区  ›  Knowledge Craving

禁止用户在任何网页上使用键盘上的“Print Scrn”/“Printscreen”键

  •  50
  • Knowledge Craving  · 技术社区  · 14 年前

    我目前正在做一个项目,在这个项目中,我需要阻止用户拍摄任何网页的快照,为此他可以使用任何普通键盘上可用的“Print Scrn”/“Printscreen”键。

    截屏

    非常感谢您的帮助,我正在使用PHP(作为服务器端语言)&我的项目的jQuery。

    11 回复  |  直到 13 年前
        1
  •  39
  •   Dirk Vollmar    14 年前

    有一些IRM(信息权限管理)工具可以做到这一点,例如通过保护Windows/DirectX API调用和监视视频内存,例如 Oracle IRM 或者像这样 Microsoft's IRM technology

    尤其是后者可能会引起兴趣,因为还有 Rights Management Add-on for Internet Explorer

    但正如其他人已经说过的,任何IRM/DRM技术都是有争议的,您应该明白,它通常会限制或惹恼您的用户。

        2
  •  53
  •   Community CDub    8 年前

    我讨厌“这不可能”这句话。以下是帮助您的所有解决方案:

    1-您可以从Haluk获得解决方案:

    <script type="text/javascript"> $(document).ready(function() {
        $(window).keyup(function(e){
          if(e.keyCode == 44){
            $("body").hide();
          }
    
        }); }); 
    </script>
    

    不过,你隐藏的身体,但已经“打印”到剪贴板。您可以触发另一个事件,将一些文本复制到剪贴板,正如您在回答“从2016年开始编辑”时所看到的 Click button copy to clipboard using jQuery

    function copyToClipboard() {
      // Create a "hidden" input
      var aux = document.createElement("input");
      // Assign it the value of the specified element
      aux.setAttribute("value", "Você não pode mais dar printscreen. Isto faz parte da nova medida de segurança do sistema.");
      // Append it to the body
      document.body.appendChild(aux);
      // Highlight its content
      aux.select();
      // Copy the highlighted text
      document.execCommand("copy");
      // Remove it from the body
      document.body.removeChild(aux);
      alert("Print screen desabilitado.");
    }
    
    $(window).keyup(function(e){
      if(e.keyCode == 44){
        copyToClipboard();
      }
    }); 
    

    这将阻止你的问题的一部分。如果用户将注意力集中在这个窗口之外的另一个对象上,他将能够截图**但也有另一个解决方案,当窗口未聚焦时,只需禁用孔体。完整的解决方案,来自您亲爱的巴西朋友:

    function copyToClipboard() {
      // Create a "hidden" input
      var aux = document.createElement("input");
      // Assign it the value of the specified element
      aux.setAttribute("value", "Você não pode mais dar printscreen. Isto faz parte da nova medida de segurança do sistema.");
      // Append it to the body
      document.body.appendChild(aux);
      // Highlight its content
      aux.select();
      // Copy the highlighted text
      document.execCommand("copy");
      // Remove it from the body
      document.body.removeChild(aux);
      alert("Print screen desabilitado.");
    }
    
    $(window).keyup(function(e){
      if(e.keyCode == 44){
        copyToClipboard();
      }
    }); 
    
    $(window).focus(function() {
      $("body").show();
    }).blur(function() {
      $("body").hide();
    });
    

    Here i try to unfocus the window, on unfocus i hide content and show modal

        3
  •  45
  •   Sjoerd    14 年前

    这是不可能的。

        4
  •  16
  •   Pekka    14 年前

    谢天谢地,这个离谱的想法不可能可靠地实现,无论是“禁用屏幕抓取”部分还是“禁用用户的Firefox扩展”部分。即使是,正如@kbok在上面的评论中指出的那样,你也没有一个 做这个。

        5
  •  14
  •   ZX12R    14 年前

    试试这个

    $(document).keyup(function(e){
      if(e.keyCode == 44) return false;
    });
    

    希望有用

        6
  •  6
  •   Leo    14 年前

    您可以使用JavaScript或Flash更改剪贴板的内容。这已经有点帮助了。

        7
  •  4
  •   Svish    14 年前

    如果是你想保护的图片,我建议你显示低质量的图像,而不是水印,只有在适当的时候才显示非水印的高质量的。

    但是是的。。。如果你想让它们无法复制。。。不要把它们放到网上。

        8
  •  4
  •   Jassar    10 年前

    没有直接的方法可以做到这一点,但是,有一种方法可以尽可能地保护您的内容不受prnt-scrn的影响。

    1. 如果java被禁用,则使您的内容不可访问,并使用一些脚本,如Artist Scope的copy protect。

    2. 检测到prnt scrn将向管理员发送消息 注册用户 这意味着只有成员才能访问的受限内容才能从中受益。发送 知识产权

    3. 一旦你的网站的窗口外,你的内容将覆盖一个覆盖,不能被删除,除非你回到你的网站,并激活它,这将重新激活前一点中提到的prnt-scrn检测代码。

    4. 剪取工具 其他类似的浏览器扩展和附加组件将毫无用处。除了我找到的一个工具叫 全页屏幕截图

      • 一个好的方法是在点击“discouse overlay”时启动一个计数器,这个计数器需要5秒或更长时间,即在这个扩展已经拍摄了快照之后
    5. 还有一个间接的方法来阻止视频捕获,仍在努力,将张贴在这里或在我的博客。

    我会更新的 this post 请检查 this quiz

        9
  •  4
  •   Piotr Kazuś    9 年前

    <p id="test">test</p>
    
    function copyToClipboard(elementId) {
    
      // Create a "hidden" input
      var aux = document.createElement("input");
    
      // Assign it the value of the specified element
      aux.setAttribute("value", document.getElementById(elementId).innerHTML);
    
      // Append it to the body
      document.body.appendChild(aux);
    
      // Highlight its content
      aux.select();
    
      // Copy the highlighted text
      document.execCommand("copy");
    
      // Remove it from the body
      document.body.removeChild(aux);
    
    }
    $(document).ready(function(){
        $(window).keyup(function(e){
          if(e.keyCode == 44){
            copyToClipboard('test');
          };
        });
    });
    
        10
  •  2
  •   SRKX    14 年前

    为什么要阻止打印屏幕?

    如果你想保护一些照片,你可能想把它放在低分辨率,并在php中以编程方式包含一些版权标识。

    我想差不多了。

        11
  •  1
  •   Haluk    12 年前

    下面是另一个解决方案:

    <script type="text/javascript"> $(document).ready(function() {
        $(window).keyup(function(e){
          if(e.keyCode == 44){
            $("body").hide();
          }
    
        }); }); </script>
    

    这类似于@ZX12R的解决方案。好处是,即使打印屏幕捕捉软件是第三方工具(如snagIt),该代码也能工作。

    你可以替换 $("body").hide(); 用更适合你的东西。例如,你可以隐藏所有的图片 $("img").hide(); 过一会儿再带他们回去。

    缺点是如果网页不是活动窗口,它将无法工作。