2014-11-24 95 views
0

因此,我試圖讓鼠標按下事件觸發,當用戶在我的div標記中點擊我的廣告時 爲什麼? ,因爲我的朋友的AdSense帳戶因無效點擊而被禁止。 我想要做的是記錄IP,一旦廣告被點擊,所有廣告將在5天后消失,然後再次出現,這意味着他們不能連續點擊廣告,導致adsence帳戶被禁止。鼠標放在包含廣告的div上

我所做的測試是這樣

<script> 
function mouseDown() { 
    alert("Yes"); 
} 
</script> 

<p id="myP" onmousedown="mouseDown()"> 
Does this work? 
</p> 

這適用於當有人點擊文本,並顯示消息「好的」。但是,當我把裏面

<div class="myAds" onmousedown="mouseDown()"> 
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> 
<ins class="adsbygoogle" 
    style="display:inline-block;width:336px;height:280px" 
    data-ad-client="ca-pub-2948xxxxxxxxx2" 
    data-ad-slot="6735xxxx36"></ins> 
<script> 
(adsbygoogle = window.adsbygoogle || []).push({}); 
</script> 
</div> 

它不工作的廣告,它的作用是轉到海峽廣告不使用任何警報

有人可以帶着這個問題,或任何其他變通幫助嗎?

+0

mousedown事件不起作用的原因是因爲廣告代碼創建一個iframe導致相同的問題描述[這裏](http://stackoverflow.com/questions/3690812/capture-click-on-div-surrounding-an-iframe)。這將更詳細地解釋爲什麼你有問題。該鏈接中提供的解決方案可能無法在您的方案中使用,但這只是一個開始。 – 2014-11-24 05:24:47

回答

0

我已經做了GitHub的項目爲這個在這裏https://github.com/DarkN3ss61/Adsense-Blocker 基本上我需要做的就是這個

var isOverGoogleAd = false; 

var ad = /adsbygoogle/; 

$(document).ready(function() 
{ 
    $('ins').live('mouseover', function() { 
     if(ad.test($(this).attr('class'))){ 
      isOverGoogleAd = true; 
     } 
    }); 
    $('ins').live('mouseout', function() { 
     if(ad.test($(this).attr('class'))){ 
      isOverGoogleAd = false; 
     } 
    }); 
}); 

$(window).blur(function(e){ 
    if(isOverGoogleAd){ 
     $.ajax({ 
      type: "post", 
      url: "AdsenseBlocker/recorder.php", 
      data: { 
       adUrl: window.location.href 
       } 
     }); 
    } 
}); 

所以,你有一個鼠標懸停和鼠標移開函數,設置布爾true或根據假天氣情況下,鼠標位於廣告內部,一旦他們點擊廣告,外部網頁變得模糊,因爲iFrame中的廣告變得焦點,所以如果isOverGoogleAd爲真,外部廣告頁變得模糊,那麼我們假設廣告被點擊