使用javascript禁用打印屏幕键 [英] disable print screen key using javascript

查看:97
本文介绍了使用javascript禁用打印屏幕键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的网站上禁用打印屏幕键。这是我到目前为止:

I'm trying to disable the print screen key on my website. This is what I have so far:

<SCRIPT type="text/javascript">
focusInput = function()
{
    document.focus();
};

processKeyEvent = function(eventType, event)
{
    if (window.event)
    {
        event = window.event;    
    }
    if(event.keyCode == 44) 
    {
        alert("Photos are copyright 2011");
        return(false);
    }
}
processKeyUp = function(event)
{
    processKeyEvent("onkeyup", event);
};

processKeyDown = function(event)
{
    processKeyEvent("onkeydown", event);
};

document.onkeyup = processKeyUp;
document.onkeydown = processKeyDown;

</SCRIPT>

但这不起作用。如何禁用打印屏幕键以防止用户制作我的网站快照?

But this isn't working. How can I disable the print screen key to prevent users from making a snapshot of my site?

推荐答案

你不能。它超出了您的控制范围,因为打印屏幕(与浏览器内打印图标/ Ctrl-P不同)不是浏览器功能,而是系统功能。

You can't. It's beyond your control, because print screen (unlike the in-browser print icon/Ctrl-P) is not a browser feature but a system feature.

此外,任何此类尝试都是徒劳的,最终会适得其反。因为你想要打印页面的乔随机用户会因为他们想要在公共汽车上阅读它或其他任何东西并且不会阻止想要滥用图像的人,因为他们总是可以利用设备这一事实。最终是在他们的物理控制之下,世界上没有任何软件可以对设备的修改做任何事情(例如使用带有屏幕捕获的监视器)。

Besides, any such attempt is futile and ultimately counter-productive. Because you will piss off the Joe Random User who wants to print the page because they want to read it on the bus or whatever and won't stop somebody who wants to abuse the images as they can always take advantage of the fact that the device is ultimately under their physical control and no software in the world can do anything against modification of the device (e.g. using a monitor with screen capture).

这篇关于使用javascript禁用打印屏幕键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆