在我的网站上我有广告。我受到点击激增的攻击。基本上,我想检测用户何时点击广告,这样我就可以在数据库中记录IP,然后我就可以禁止点击次数最多的用户。现在我知道大多数广告都是通过iframe标签运行的,但我还能做我想做的吗?任何想法都将不胜感激。
尚未对此进行测试,但它应该可以工作。它基本上是在模糊事件启动之前检查鼠标是否在广告上。
jQuery(function( $ ){
var isOverGoogleAd = false;
$( "iframe[ id *= google ]" ).mouseover(
function(){
isOverGoogleAd = true;
}
)
.mouseout(
function(){
isOverGoogleAd = false;
}
);
$( window ).blur(
function(){
if (isOverGoogleAd){
$.ajax({
type: "post",
url: "track.php",
data: {
adUrl: window.location.href
}
});
}
})
.focus();
});
从这里拍摄。