我需要在我的网页上点击一个按钮,在用户看到内容之前必须点击该按钮,并且按钮必须与内容位于同一页面中:如下所示:http://imgonion.com/img-516851517c10d.html(上面有成人广告! !)。该按钮用于检查用户是人还是机器人
答案 0 :(得分:2)
我可能会这样做reverse honeypot captcha - 将鼠标悬停在按钮上应确认,用户是人。代码可能如下所示:
HTML:
<button id="showContext">Show content</button>
<div id="content"></div>
的javascript / jquery的:
$(document).ready(function(){
var isHuman = false;
$('#showContext').attr('tabIndex',-1).mouseenter(function(){
isHuman = true;
}).mouseleave(function(){
isHuman = false;
}).click(function(){
if (isHuman) {
$('#content').html('Hello human');
$.ajax("example.php?isHuman="+(isHuman?'yes':'no'))
.done(function(data) { $('#content').html(data); })
.fail(function() { alert("connection error"); });
} else {
//alert('das booooot detected');
}
});
});
我不确定此解决方案是否能100%正常运行。一些机器人可以执行javascript,所以最安全的方法是使用验证码 相关讨论:Programmatic Bot Detection