防止在网页中复制文本

时间:2012-01-21 22:57:30

标签: html copy-paste copy-protection

我有测验申请。机器人在聊天中提出不同的问题时,这些问题属于知识的不同领域。首先回答问题的用户,获得积分。问题是,有些用户在Google上搜索答案。我想以某种方式阻止用户从网页上回复问题并使用谷歌搜索答案。

我甚至不确定,这是可能的,无论如何可能有人有任何想法

11 个答案:

答案 0 :(得分:70)

下面: How to disable text selection highlighting using CSS?

-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;

禁止他们在触发窗口的onBlur事件时回答。他们仍然可以使用其他设备,但他们无法在同一台计算机上作弊。

答案 1 :(得分:21)

在您粘贴问题的div标签中,添加以下代码行:

<div id="test" onmousedown='return false;' onselectstart='return false;'>

这样可以防止复制标签内的任何内容......

答案 2 :(得分:11)

没有好办法做到这一点。骗子将能够解决几乎所有事情。

唯一想到的是将问题输出为动态生成的图像。这样可以防止复制粘贴。但是,您必须确定实际上有多少保护 - 大多数简短的问题可以立即输入Google,不是吗?

答案 3 :(得分:6)

请注意,想要通过浏览器端的Greasemonkey脚本等覆盖无复制规则的人可以通过Google找到此问题。

除了选择禁用之外,我在至少一个网站上看到了以下策略:

<body oncopy="return false" onpaste="return false" oncut="return false">...</body>

答案 4 :(得分:5)

您还可以将页面设为图像而不是html / text。

从图像中复制文本并不容易。它必须保存和OCR。

答案 5 :(得分:3)

您是否可以在包含测验/问题的元素顶部放置透明PNG?

答案 6 :(得分:1)

如果您使用的是JQuery,请使用:

function disableSelection(target){
    $(function() {
         $(this).bind("contextmenu", function(e) {
             e.preventDefault();
         });
     }); 
     if (typeof target.onselectstart!="undefined") //For IE 
          target.onselectstart=function(){return false}
     else if (typeof target.style.MozUserSelect!="undefined") //For Firefox
          target.style.MozUserSelect="none"
     else //All other route (For Opera)
          target.onmousedown=function(){return false}
     target.style.cursor = "default";
}

将此功能调用到要禁用的位置。

$(document).ready(function(){
     disableSelection(document.body);
});

答案 7 :(得分:1)

对于将来的Google员工,他们可能不想阻止突出显示或不想让用户复制有限数量的字符:

  function anticopy(event: ClipboardEvent) {    
    // @ts-ignore
    const clipboardData = event.originalEvent.clipboardData || window.clipboardData || event.originalEvent.clipboardData;
    const txt = window.getSelection().toString() || editor.getWin().getSelection().toString();
    if (txt.length > 200) {
      const no = 'You cannot copy more than 200 characters.';
      clipboardData.setData('text', no);
      clipboardData.setData('text/html', `<p>${no}</p>`);
    } else {
      const html = `<p><span data-user="${user.data.id}"></span> ${txt}</p>`;
      clipboardData.setData('text', txt);
      clipboardData.setData('text/html', html);
    }

    event.preventDefault();
  }

答案 8 :(得分:0)

您可以使用谷歌查询每个给定的答案,如果没有完全匹配,用户很可能已经自己键入了它,您可以授予积分。

答案 9 :(得分:0)

<head>
<script type='text/javascript'>
var isCtrl = false;
document.onkeyup=function(e)
{
if(e.which == 17)
isCtrl=false;
}
document.onkeydown=function(e)
{
if(e.which == 123)
isCtrl=true;
if (((e.which == 85) || (e.which == 65) || (e.which == 88) || (e.which == 67) || (e.which == 86) || (e.which == 2) || (e.which == 3) || (e.which == 123) || (e.which == 83)) && isCtrl == true)
{
alert('This is Function Disabled');
return false;
}
}
// right click code
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
    alert('This is Function Disabled');
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
//select content code disable  alok goyal
function killCopy(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
if (window.sidebar){
document.onmousedown=killCopy
document.onclick=reEnable
}
</script>
</head>

<body>
  <h2>Disable code right click and ctrl a, ctrl u, ctrl c, ctrl v key and f12 and select content code</h2>
  <div>
    Some text...
  </div>
</body>

答案 10 :(得分:0)

您可以使用ArtistScope网站保护系统(ASPS)来防止包括屏幕截图和录制在内的所有复制,也可以仅使用ArtisBrowser来防止复制粘贴和拖放操作。这是最安全的解决方案,并且经过验证。全球的在线导师和大学正在使用。