Zeaks

Responsive Google Adsense

May 8th, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <!-- GOOGLE ADSENSE www.zeaks.org-->
  2. <div id="responsive-adsense">
  3. <script type="text/javascript">
  4.  
  5. adUnit = document.getElementById("responsive-adsense");
  6. adWidth = adUnit.offsetWidth;
  7.  
  8. /* Replace this with your AdSense Publisher ID */
  9. google_ad_client = "PUB ID HERE";
  10.  
  11.     if ( adWidth >= 768 ) {
  12.     /* Leaderboard 728x90 */
  13.     google_ad_slot = "ADSLOT HERE";
  14.     google_ad_width = 768;
  15.     google_ad_height = 90;
  16.     } else if ( adWidth >= 468 ) {
  17.     /* Banner (468 x 60) */
  18.     google_ad_slot = "ADSLOT HERE";
  19.     google_ad_width = 468;
  20.     google_ad_height = 60;
  21.     } else if ( adWidth >= 336 ) {
  22.     /* Medium Rectangle (320 x 50) */
  23.     google_ad_slot = "ADSLOT HERE";
  24.     google_ad_width = 320;
  25.     google_ad_height = 50;
  26.     } else {
  27.     /* Do not display the Google Ad */
  28.     google_ad_slot = "0";
  29.     adUnit.style.display = "none";
  30.     }
  31. </script>
  32.  
  33. <script type="text/javascript"
  34. src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  35. </script>
  36. </div>
  37. <!-- END GOOGLE ADSENSE -->
Add Comment
Please, Sign In to add comment