开发者

Hide Adsense based on cookie

I'd like to not show Adsense for logged in members, using javascript and based on a cookie. Both types of members see the same html, as it's cached from the server. I know I could just hide the containing div, but I开发者_StackOverflow社区 believe that is against the TOS and would also count as a false impression. The actual google script cannot be changed. I think I just need to somehow stop it loading the show_ads.js using some javascript before or after the google code.

<script type="text/javascript"><!--
google_ad_client = "ca-pub-555";
google_ad_slot = "555";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


The best bet would be to remove the adsense code using server-side scripting (PHP, ASP, etc). Here's some pseudo code for PHP:

<?php
if (!$loggedin) {
?>

<script type="text/javascript"><!--
google_ad_client = "ca-pub-555";
google_ad_slot = "555";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

<?php
}
?>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜