开发者

Google AdSense and AdBlock

开发者 https://www.devze.com 2023-03-21 05:54 出处:网络
I have Google AdSense ads on my site, and AdBlock blocks them, which is fine. When they are blocked, I would like to display alternate content. The problem is that when the ads are blocked, there are

I have Google AdSense ads on my site, and AdBlock blocks them, which is fine. When they are blocked, I would like to display alternate content. The problem is that when the ads are blocked, there are two things that can happen:

1) The ad is complete suppressed by AdBlock, the height and width of the AdSense ad are 0, and most of the AdSense code is not generated.

2) The AdSense ad content is blocked, but the height and width are set and the AdSense code is generated.

Option 1 is perfect because it allows me to check the height of the container, or for tags that AdSense renders, and show my alternate content if the height is 0, or if a specific AdSense tag doesn't exist. However, when option 2 occurs, I don't know what I can do to display my alternate content, and the AdSense ads take up their required h开发者_运维百科eight and width, but don't display any content, making my site look broken.

Has anyone else had any experience with this issue? My site is in .net 4.0 and I've only tested AdBlock in Chrome v12 so far.


Sounds like you have option 1 covered (if height is 0, ajax in your own ads).

For option 2, isn't that add area blank or hidden?

So maybe something like this would work:

var adNode  = $('#Google_Ad_Container');

if ( adNode.is (':hidden')  ||  ! /\S/.test (adNode.text () ) )
{
    // Ajax in your ads here...
}


Set a min-height/width and have the background of the box be an image / alt content (I assume it will be a message saying please whitelist us)

Set the image to no-repeat and background color to match the background of the image.

No matter the size of the box now, you'll have your message there.

I hope I made sense.

0

精彩评论

暂无评论...
验证码 换一张
取 消