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

时间:2022-07-11 19:18:35

I am currently doing a project, in which I need to stop the user from taking the snapshot of any Web Page, for which he can use the "Print Scrn" / "Printscreen" key available in any of the normal keyboards.

我目前正在做一个项目,在这个项目中,我需要阻止用户获取任何Web页面的快照,这样用户就可以使用任何正常键盘中可用的“Print Scrn”/“Printscreen”键。

I have been trying to find its solution, but in vain. If possible, I need to take into account of the "Screengrab" add-on of the Firefox browser, by stopping it also.

我一直试图找到它的解决办法,但没有成功。如果可能的话,我需要考虑到Firefox浏览器的“屏幕抓取”插件,也要停止它。

Any help is greatly appreciated, and I am using PHP (as server-side language) & jQuery for my project.

非常感谢您的帮助,我在项目中使用了PHP(服务器端语言)和jQuery。

11 个解决方案

#1


37  

You can't disable screen grabbing from the Web browser, it would only be possible by installing additional software on the user's PC.

您不能禁用Web浏览器的屏幕抓取,只能通过在用户的PC上安装其他软件来实现。

There are some IRM (Information Rights Management) tools available that do that e.g. by protecting Windows/DirectX API calls and also monitoring video memory such as Oracle IRM or such as Microsoft's IRM technology.

有一些IRM(信息权利管理)工具可以做到这一点,例如通过保护Windows/DirectX API调用和监控视频内存,如Oracle IRM或微软的IRM技术。

Especially the latter might be of interest as there is also a Rights Management Add-on for Internet Explorer.

特别是后者可能是感兴趣的,因为Internet Explorer还有一个权限管理附加组件。

But as other already said, any IRM/DRM technology is controversy and you should understand that it most often will limit or annoy your users.

但是正如前面已经提到的,任何IRM/DRM技术都是有争议的,您应该理解,它通常会限制或惹恼您的用户。

#2


43  

This is not possible.

这是不可能的。

#3


31  

I hate the "it's not possible" sentence. Here's all solutions combined to help you:

我讨厌“不可能”这句话。这里是所有的解决方案结合起来帮助你:

1- You can grab the solution from Haluk:

1-你可以从Haluk获取解决方案:

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

    }); }); 
</script>

HOWEVER, you hide body, but's already "printed" to clipboard. You can fire another event that copy some text to your clipboard, as you can see on this answer "Edit as of 2016" Click button copy to clipboard using jQuery , it's something like this:

然而,你隐藏身体,但已经“打印”到剪贴板。您可以启动另一个事件,将一些文本复制到您的剪贴板,您可以在“2016年编辑”的回答中看到,使用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();
  }
}); 

This will block a part of your problem. If user focus on another object outside this windows he will be able to take screenshots. **But there's another solution to that as well, simply disable the hole body when window get's unfocused. Full solution, from your dear brazillian friend:

这会阻止你的部分问题。如果用户关注这个窗口之外的另一个对象,他将能够进行屏幕截图。**但也有另一个解决方案,当窗口不集中时,简单地关闭这个孔体。完全解决方案,来自你亲爱的巴西朋友:

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's the example working:

这是示例工作:

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

#4


15  

Thankfully, this outrageous idea is not possible to implement reliably, neither the "disable screen grab" part nor the "disable user's Firefox extensions" one. And even if it were, as @kbok points out in his comment above, you don't have a right to do this.

值得庆幸的是,这个惊人的想法不可能可靠地实现,无论是“禁用屏幕抓取”部分还是“禁用用户的Firefox扩展”部分。即便如此,正如@kbok在上面的评论中指出的那样,你也没有权利这么做。

The only way to protect your content online is copyright laws - mentioning those is often enough to scare people away from misusing it! - or not showing it at all.

保护你的在线内容的唯一方法是版权法——提及这些往往足以吓到人们不去滥用它!-或者根本不展示。

#5


13  

Try this

试试这个

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

Hope it works

希望它的工作原理

#6


6  

You can change the contents of the clipboard using JavaScript or Flash. This already helps a bit.

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

#7


4  

Like @Sjoerd said, this is not possible.

就像@Sjoerd说的,这是不可能的。

If it is pictures you want to protect, I suggest you for example display lower quality images that are watermarked instead and only display the non watermarked high quality ones when appropriate.

如果是你想要保护的图片,我建议你以低质量的有水印的图片代替,只在适当的时候显示没有水印的高质量的图片。

But yeah... If you want them to be impossible to copy... don't put them online.

但是是的…如果你想让他们不可能复制……不要把它们放到网上。

#8


3  

There is no direct method to do that, however, there is a way to protect your content as much as possible from prnt scrn.

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

The idea is this:

我们的想法是这样的:

  1. make your content inaccessible if java is disabled, and use some script like Artist Scope's copy protect.

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

  2. Detecting prnt scrn will send a message to the admin with the registered user info, this means that restricted content that is accessible by members only can benefit from this. sending IP addresses sounds like a good idea, but banning IPs is not, so you won't gain a lot of benefit from that.

    检测prnt scrn将会向管理员发送一个信息,这意味着用户可以访问的受限内容只会从中受益。发送IP地址听起来是个好主意,但是禁止IP地址并不是一个好主意,所以你不会从中得到很多好处。

  3. Once outside your website's window, your content will be covered with an overlay that can't be removed unless you get back to your website and activate it, which will re-activate the prnt scrn detection code mentioned in the previous point.

    一旦出了你的网站窗口,你的内容将覆盖一个覆盖层,除非你回到你的网站并激活它,否则不能删除它,这将重新激活前面提到的prnt scrn检测代码。

  4. If the device is a mobile, you can either hide images, or as in my case, redirect to a "we're sorry" page.

    如果设备是移动的,你可以隐藏图像,或者在我的情况下,重定向到“我们很抱歉”的页面。

  5. snipping tool and other similar browser extensions and add-ons will be useless. except one tool that I have found called full page screen capture

    剪切工具和其他类似的浏览器扩展和插件将毫无用处。除了我发现的一个工具叫做全页屏幕截图

    • this tool captures web content after about 3 seconds from pressing button, which is enough time to dismiss the overlay and get back to your content
    • 这个工具在按下按钮大约3秒后捕获web内容,这足够消除覆盖并返回到内容
    • a good turnaround is to start a counter when "dismiss overlay" is clicked that will need 5 seconds or more, ie. after this extension has already taken a snapshot
    • 一个好的转变是当点击“解散叠加”时启动一个计数器,这将需要5秒或更长时间。在此扩展之后,已经获取了快照
  6. There's also an indirect method to prevent video capture, still working on it, will post it here or in my blog.

    还有一种间接的方法,可以防止视频捕捉,还在处理,会在这里或我的博客上发布。

  7. If your content is really that much worth it, users might still capture it using their cameras, there might be a method for that too! But I sill need to do some research before talking about it.

    如果你的内容真的很有价值,用户可能仍然会用他们的相机捕捉到它,可能也会有这样的方法!但在讨论这个问题之前,我还需要做些调查。

I will be updating this post in my blog for other techniques that I've used/ will use for more protection. Please check this quiz (still under development) for a demo.

我将在我的博客中更新这篇文章,以获得我使用/将用于更多保护的其他技术。请检查这个测试(仍在开发中)的演示。

#9


3  

You can copy to clipboard something else, when user click key print screen. This is example and I copy user text.

当用户点击打印键时,你可以复制到剪贴板上。这是一个例子,我复制用户文本。

<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  

Why do you want to prevent the print screen?

为什么要阻止打印屏幕?

If it's some photos you want to protect, you might want to put it in low resolution, and include some kind of copyright logo programmatically in php.

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

I think that's pretty much it.

我觉得差不多了。

#11


1  

Here is another solution:

这是另一个解决方案:

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

    }); }); </script>

This is similar to @ZX12R's solution. The upside is this code will work even if the print screen catching software is a 3rd party tool (eg snagIt).

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

You can replace $("body").hide(); with something which will suit you better. For instance you can hide all the pictures $("img").hide(); and maybe show them back a second later.

你可以换美元(“身体”)hide();有更适合你的东西。例如,可以隐藏所有的图片$(“img”).hide();也许会在一秒钟后给他们看。

The downside is it will not work if the web page is not the active window.

缺点是,如果web页面不是活动窗口,它将不起作用。

#1


37  

You can't disable screen grabbing from the Web browser, it would only be possible by installing additional software on the user's PC.

您不能禁用Web浏览器的屏幕抓取,只能通过在用户的PC上安装其他软件来实现。

There are some IRM (Information Rights Management) tools available that do that e.g. by protecting Windows/DirectX API calls and also monitoring video memory such as Oracle IRM or such as Microsoft's IRM technology.

有一些IRM(信息权利管理)工具可以做到这一点,例如通过保护Windows/DirectX API调用和监控视频内存,如Oracle IRM或微软的IRM技术。

Especially the latter might be of interest as there is also a Rights Management Add-on for Internet Explorer.

特别是后者可能是感兴趣的,因为Internet Explorer还有一个权限管理附加组件。

But as other already said, any IRM/DRM technology is controversy and you should understand that it most often will limit or annoy your users.

但是正如前面已经提到的,任何IRM/DRM技术都是有争议的,您应该理解,它通常会限制或惹恼您的用户。

#2


43  

This is not possible.

这是不可能的。

#3


31  

I hate the "it's not possible" sentence. Here's all solutions combined to help you:

我讨厌“不可能”这句话。这里是所有的解决方案结合起来帮助你:

1- You can grab the solution from Haluk:

1-你可以从Haluk获取解决方案:

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

    }); }); 
</script>

HOWEVER, you hide body, but's already "printed" to clipboard. You can fire another event that copy some text to your clipboard, as you can see on this answer "Edit as of 2016" Click button copy to clipboard using jQuery , it's something like this:

然而,你隐藏身体,但已经“打印”到剪贴板。您可以启动另一个事件,将一些文本复制到您的剪贴板,您可以在“2016年编辑”的回答中看到,使用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();
  }
}); 

This will block a part of your problem. If user focus on another object outside this windows he will be able to take screenshots. **But there's another solution to that as well, simply disable the hole body when window get's unfocused. Full solution, from your dear brazillian friend:

这会阻止你的部分问题。如果用户关注这个窗口之外的另一个对象,他将能够进行屏幕截图。**但也有另一个解决方案,当窗口不集中时,简单地关闭这个孔体。完全解决方案,来自你亲爱的巴西朋友:

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's the example working:

这是示例工作:

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

#4


15  

Thankfully, this outrageous idea is not possible to implement reliably, neither the "disable screen grab" part nor the "disable user's Firefox extensions" one. And even if it were, as @kbok points out in his comment above, you don't have a right to do this.

值得庆幸的是,这个惊人的想法不可能可靠地实现,无论是“禁用屏幕抓取”部分还是“禁用用户的Firefox扩展”部分。即便如此,正如@kbok在上面的评论中指出的那样,你也没有权利这么做。

The only way to protect your content online is copyright laws - mentioning those is often enough to scare people away from misusing it! - or not showing it at all.

保护你的在线内容的唯一方法是版权法——提及这些往往足以吓到人们不去滥用它!-或者根本不展示。

#5


13  

Try this

试试这个

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

Hope it works

希望它的工作原理

#6


6  

You can change the contents of the clipboard using JavaScript or Flash. This already helps a bit.

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

#7


4  

Like @Sjoerd said, this is not possible.

就像@Sjoerd说的,这是不可能的。

If it is pictures you want to protect, I suggest you for example display lower quality images that are watermarked instead and only display the non watermarked high quality ones when appropriate.

如果是你想要保护的图片,我建议你以低质量的有水印的图片代替,只在适当的时候显示没有水印的高质量的图片。

But yeah... If you want them to be impossible to copy... don't put them online.

但是是的…如果你想让他们不可能复制……不要把它们放到网上。

#8


3  

There is no direct method to do that, however, there is a way to protect your content as much as possible from prnt scrn.

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

The idea is this:

我们的想法是这样的:

  1. make your content inaccessible if java is disabled, and use some script like Artist Scope's copy protect.

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

  2. Detecting prnt scrn will send a message to the admin with the registered user info, this means that restricted content that is accessible by members only can benefit from this. sending IP addresses sounds like a good idea, but banning IPs is not, so you won't gain a lot of benefit from that.

    检测prnt scrn将会向管理员发送一个信息,这意味着用户可以访问的受限内容只会从中受益。发送IP地址听起来是个好主意,但是禁止IP地址并不是一个好主意,所以你不会从中得到很多好处。

  3. Once outside your website's window, your content will be covered with an overlay that can't be removed unless you get back to your website and activate it, which will re-activate the prnt scrn detection code mentioned in the previous point.

    一旦出了你的网站窗口,你的内容将覆盖一个覆盖层,除非你回到你的网站并激活它,否则不能删除它,这将重新激活前面提到的prnt scrn检测代码。

  4. If the device is a mobile, you can either hide images, or as in my case, redirect to a "we're sorry" page.

    如果设备是移动的,你可以隐藏图像,或者在我的情况下,重定向到“我们很抱歉”的页面。

  5. snipping tool and other similar browser extensions and add-ons will be useless. except one tool that I have found called full page screen capture

    剪切工具和其他类似的浏览器扩展和插件将毫无用处。除了我发现的一个工具叫做全页屏幕截图

    • this tool captures web content after about 3 seconds from pressing button, which is enough time to dismiss the overlay and get back to your content
    • 这个工具在按下按钮大约3秒后捕获web内容,这足够消除覆盖并返回到内容
    • a good turnaround is to start a counter when "dismiss overlay" is clicked that will need 5 seconds or more, ie. after this extension has already taken a snapshot
    • 一个好的转变是当点击“解散叠加”时启动一个计数器,这将需要5秒或更长时间。在此扩展之后,已经获取了快照
  6. There's also an indirect method to prevent video capture, still working on it, will post it here or in my blog.

    还有一种间接的方法,可以防止视频捕捉,还在处理,会在这里或我的博客上发布。

  7. If your content is really that much worth it, users might still capture it using their cameras, there might be a method for that too! But I sill need to do some research before talking about it.

    如果你的内容真的很有价值,用户可能仍然会用他们的相机捕捉到它,可能也会有这样的方法!但在讨论这个问题之前,我还需要做些调查。

I will be updating this post in my blog for other techniques that I've used/ will use for more protection. Please check this quiz (still under development) for a demo.

我将在我的博客中更新这篇文章,以获得我使用/将用于更多保护的其他技术。请检查这个测试(仍在开发中)的演示。

#9


3  

You can copy to clipboard something else, when user click key print screen. This is example and I copy user text.

当用户点击打印键时,你可以复制到剪贴板上。这是一个例子,我复制用户文本。

<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  

Why do you want to prevent the print screen?

为什么要阻止打印屏幕?

If it's some photos you want to protect, you might want to put it in low resolution, and include some kind of copyright logo programmatically in php.

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

I think that's pretty much it.

我觉得差不多了。

#11


1  

Here is another solution:

这是另一个解决方案:

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

    }); }); </script>

This is similar to @ZX12R's solution. The upside is this code will work even if the print screen catching software is a 3rd party tool (eg snagIt).

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

You can replace $("body").hide(); with something which will suit you better. For instance you can hide all the pictures $("img").hide(); and maybe show them back a second later.

你可以换美元(“身体”)hide();有更适合你的东西。例如,可以隐藏所有的图片$(“img”).hide();也许会在一秒钟后给他们看。

The downside is it will not work if the web page is not the active window.

缺点是,如果web页面不是活动窗口,它将不起作用。