我试图在我的网站上忽略 Ctrl-C 但我卡住了。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript">
function whichButton(event)
{
if (event.button==2)//RIGHT CLICK
{
alert("Not Allow Right Click!");
}
}
function noCTRL(e)
{
var code = (document.all) ? event.keyCode:e.which;
var msg = "Sorry, this functionality is disabled.";
if (parseInt(code)==17) //CTRL
{
alert(msg);
window.event.returnValue = false;
}
}
</script>
</head>
<body>
<form method="">
<strong>Not Allow Paste </strong><BR>
<input type="text" value="" onMouseDown="whichButton(event)" onKeyDown="return noCTRL(event)"/>
</form>
</body>
</html>
我试过这段代码,但它只能忽略右键单击。
如何忽略 Ctrl-C?
最佳答案
但是如果有人想复制您的内容,他们可以。它只会使使用起来更难、更耗时。
还有
关于这个 Ctrl-C 你可以添加 javascript 来阻止它,但它没有用,因为用户总是可以禁用 javascript。事实上很多用户会觉得拦截右键很烦人。
如果您正在构建一个 Intranet 应用程序,或者您可以发布一个集成浏览器供用户查看该应用程序,那么所有这些都可能有意义。使用公共(public) html,我相信它甚至不值得尝试。一种解决方案是使用 Flash 或其他插件构建您的应用程序。这样您就可以加密发送给客户端的所有内容。
关于javascript - 如何在网络浏览器上忽略 Control+C(复制),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9955178/