问题
So there is a lot of conflicting posts and mostly outdated info on this, how exactly would I detect people blocking google ads?
My ads for example are shown like this:
<div class="row gol-news-ad hidden-tablet hidden-phone">
<div class="span9">
<div class="alert alert-info text-center">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-7221863530030989";
/* gol top above news big */
google_ad_slot = "5565571944";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</div>
</div>
Would there be a way to show a message like "Please support us and don't block our ads!" if they have blocked them?
I've tried adding:
$(window).load(function() {
if(typeof(window.google_render_ad)=="undefined")
{
var thep = document.getElementById('mainad');
var content = document.createTextNode("Please disable adblocker!");
thep.appendChild(content);
}
}
And wrapping the adcode in a "mainad" p element to no luck.
来源:https://stackoverflow.com/questions/16588319/how-to-detect-ad-blocking-and-show-a-message