Goo*_*Prs 5 javascript jquery zeroclipboard
我想在 JavaScript 中创建函数,在使用打印屏幕后更改剪贴板的值。那可能吗?
$(document).keyup(function(e){
if(e.keyCode == 44)
//change clipboard value code
});
编辑:我找到了 ZeroClipboard 库,但每个教程都是关于使用按钮复制的。我只想更改剪贴板的值。
</body>尝试在关闭网站之前在标签之间包含此内容<script> </script>
/** TO DISABLE SCREEN CAPTURE **/
document.addEventListener('keyup', (e) => {
if (e.key == 'PrintScreen') {
navigator.clipboard.writeText('');
alert('Screenshots disabled!');
}
});
/** TO DISABLE PRINTS WHIT CTRL+P **/
document.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.key == 'p') {
alert('This section is not allowed to print or export to PDF');
e.cancelBubble = true;
e.preventDefault();
e.stopImmediatePropagation();
}
});
/* TO DO: There are combinations that remain to be solved
--> Windows+Shift+S
*/
Run Code Online (Sandbox Code Playgroud)
小智 6
还有另一种方法可以在您的网站中禁用打印屏幕(它适用于我的网站)。单击此处转到我的笔 (Codepen.io)。这里还有一个片段:
document.addEventListener("keyup", function (e) {
var keyCode = e.keyCode ? e.keyCode : e.which;
if (keyCode == 44) {
stopPrntScr();
}
});
function stopPrntScr() {
var inpFld = document.createElement("input");
inpFld.setAttribute("value", ".");
inpFld.setAttribute("width", "0");
inpFld.style.height = "0px";
inpFld.style.width = "0px";
inpFld.style.border = "0px";
document.body.appendChild(inpFld);
inpFld.select();
document.execCommand("copy");
inpFld.remove(inpFld);
}
function AccessClipboardData() {
try {
window.clipboardData.setData('text', "Access Restricted");
} catch (err) {
}
}
setInterval("AccessClipboardData()", 300);Run Code Online (Sandbox Code Playgroud)
body {
background-color: #00FF00;
}Run Code Online (Sandbox Code Playgroud)
<html>
<head>
<title>Disable Print Screen</title>
</head>
<body>
<h2>Print screen is disabled</h2>
<p>Click anywhere on green background and try to "print screen" the content (and then see the result in Paint or simulair software)
</body>
</html>Run Code Online (Sandbox Code Playgroud)
点击这里查看原始代码
| 归档时间: |
|
| 查看次数: |
55850 次 |
| 最近记录: |