How can I disable print-screen functionality for a webpage in all browsers?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 12:48:04

问题


Using the following we can disable print-screens or screenshots in Internet Explorer:

<body onload=setInterval(\"window.clipboardData.setData(\'text\',\'\')\",2) 

oncontextmenu=\"return false\" onselectstart=\"return false\">

But these don\'t work in Mozilla, Chrome and other browsers.

Is there a better way to disable print-screens/screenshots?


回答1:


What makes you think it's your decision if people should be able to take screenshots or not?

Luckily no browser but IE allows you to access the clipboard via JavaScript so you are out of luck :)

By the way, if I visited your site and it messed up my clipboard (it overwrites anything in there, even if it's unrelated to your site) - I might have stored something in it that I've just cut from some file and I was going to paste in a different file and thanks to your site it would now be lost.

So, the conclusion is: Stop doing crap like that.




回答2:


If you're giving a sample of something you'll later want to sell to a customer then one thing you can do is have an image saying 'Copyrighted Material' and use it as a background on the webpage like a watermark. Disabling text selection, context menus and copying with CTRL + A is possible in both I.E. and Chrome, although I forget right now how I've done this (it was a CSS solution, and quite simple, too). Anyway, so that's one thing that can be done - if you can't protect it, spoil it so that it's unusable. Stock image sites use this method by watermarking their pictures, something that can be implemented on websites server-side with php, etc.




回答3:


Try onKeyPress catch the PrtScr button, and return false. It's not pretty but I think that would work.




回答4:


window.addEventListener("keyup",kPress,false);
function kPress(e)
{ 
var c=e.keyCode||e.charCode; 
if (c==44) alert("print screen");
}


来源:https://stackoverflow.com/questions/5938466/how-can-i-disable-print-screen-functionality-for-a-webpage-in-all-browsers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!