I am working on my responsive design but have problems with adsense.
I have an ad that should appear on the desktop design, but not on the mobile design. Therefore, the ad code should be placed in html only if the website is viewed on the desktop. This is possible with css using display: none, but it is against adsense TOS, therefore not a solution.
I think this is possible with a PHP class like http://mobiledetect.net , but I prefer to check the width of the browser and then decide what to do.
Adsense has an approved example, as shown below, but can I use it for my purpose?
<script type="text/javascript">
google_ad_client = "ca-publisher-id";
width = document.documentElement.clientWidth;
google_ad_slot = "1234567890";
google_ad_width = 320;
google_ad_height = 50;
if (width > 500) {
google_ad_slot = "3456789012";
google_ad_width = 468;
google_ad_height = 60;
}
if (width > 800) {
google_ad_slot = "2345678901";
google_ad_width = 728;
google_ad_height = 90;
}
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Hope someone can point me in the right direction.