2012-01-21 53 views
25

我有測驗應用程序。機器人在聊天時提出不同的問題,這些問題屬於知識的不同領域。先回答問題的用戶,獲得積分。問題是,有些用戶在Google上搜索答案。我想以某種方式防止用戶從網頁和Google搜索答案中應對問題。防止在網頁上覆制文字

我什至不知道,這是可能的,反正大概有人有任何想法

+3

你打算如何阻止有記憶功能的人從輸入東西到搜索引擎? –

+0

打字需要更多時間。在輸入的同時,下一個問題將被要求 – Anton

+0

使屏幕全屏,並且如果它離開焦點或退出全屏檢測並永久取消測試。 –

回答

58

這裏: 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事件被觸發回答禁止他們。他們仍然可以使用其他設備,但他們無法在同一臺計算機上作弊。

+0

不錯,謝謝 – Anton

+0

這也適用於放置容器div的地方,您可以從Google Maps,MapQuest等顯示地圖。 –

+0

太棒了。我使用了[foggy插件](http://nbartlomiej.github.io/foggy/)在訂閱之前隱藏內容。 – JacobLett

9

還有就是要做到這一點沒有什麼好辦法。騙子將能夠解決幾乎所有問題。

想到的唯一事情就是將問題輸出爲動態生成的圖像。這將防止複製粘貼。但是,您必須確定實際上有多少保護措施 - 大多數簡短的問題都可以立即輸入Google,難道不是嗎?

0

您可以使用谷歌查詢每個給定的答案,如果沒有完全匹配,很可能是用戶輸入了它自己,並且您可以授予積分。

3

您可以在包含測驗/問題的元素頂部放置透明的PNG嗎?

16

在您的div標籤,你貼上你的問題,添加以下代碼行:

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

這將防止任何事物是在標籤內複製...

4

你也可以將該頁面的圖像,而不是HTML /文本。

從圖像中複製文本並不容易。這將不得不被保存和OCR'd。

3

請注意,這個問題可能是通過谷歌誰想要覆蓋通過Greasemonkey腳本或類似的瀏覽器端的無拷貝規則。

除了選擇禁用,我已經看到了以下策略中至少一個網站:

<body oncopy="return false" onpaste="return false" oncut="return false">...</body> 
-1
<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> 
0

如果您正在使用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); 
});