开发者

How to hide empty adsense box

开发者 https://www.devze.com 2023-01-12 15:03 出处:网络
How to hide adsense iframe/div when开发者_如何学Go no ads for this box are available?The official recommendation from Google is to use CSS.

How to hide adsense iframe/div when开发者_如何学Go no ads for this box are available?


The official recommendation from Google is to use CSS.

Google uses data-ad-status to indicate if an ad placement was filled or not, which can be targeted to apply CSS to hide the element.

ins.adsbygoogle[data-ad-status="unfilled"] {
    display: none !important;
}

From Google's support article: https://support.google.com/adsense/answer/10762946?hl=en


To avoid violating AdSense's terms of service, I'd recommend setting up Google's DFP SB - it's a free adserver and really easy to link your adsense account. Then create a house ad (any ad that advertises a paid version of your site or your twitter account, etc) you can then set-up DFP to serve your house ad anytime Adsense can't fill.


Get the name/ID of the iframe and just use .hide()

If you can't find a suitable selector, wrap the ad in a div with an id e.g.

<div id='some_google_ad'>
 // Google add code goes in here
</div>

and in your javacsript

$("#some_google_ad").hide();

Note there is no way of telling if your ad or ads are showing a community service announcement or a paid advertisement.

And I would suspect that having an adsense ad container on a page and having it hidden would be against the adsense TOS.


much better idea: http://www.google.com/support/adsense/bin/answer.py?hl=en&answer=21590&rd=1

0

精彩评论

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