MyBB Community Forums

Full Version: Implement a theme's bg color into a Google Ad's bg color.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Heh, as you can tell.. I'm doing some really complicated stuff. This is mainly for CreateMyBB, though. I'm trying to take a theme's background color, say.. the welcome_block, and then put that background color into the ad:

<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxx";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "EFEFEF";
google_color_bg = "theme's background color (variable?)";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Any help would be greatly appreciated.
<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxx";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "EFEFEF";
google_color_bg = "theme's background color (variable?)";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//--></script>

It's not javascript. Try using

<style type="text/css"><!--
google_ad_client = "pub-xxxxxx";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "EFEFEF";
google_color_bg = "theme's background color (variable?)";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//--></style>
That would break Adsense's terms, which.. you can't really do without getting banned. Is there another way?
decswxaqz Wrote:It's not javascript. Try using

It is Javascript. They are Javascript variables that the Google script uses.

Sorry. I was wrong, the code was Javascript and wasn't trying to be CSS.

I'm not sure of an easy way to get the background colour of the welcome block easily. Perhaps you could just hard code the background colour value into the google script?

Maybe you could use something like (not tested)
element = document.getElementById("panel");
google_color_bg = element.style.backgroundColor;
Not sure on how to get the background colour... I know it's something like that...
Hm, the way I'm doing it is that I'm using phpAdsNew to globally change ads, and the code I put in the templates to show the ads is just a javascript code. I could also make it into a php code. Here's the current code I'm using in the header:

<script language='JavaScript' type='text/javascript' src='http://createmybb.com/adservices/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
   if (!document.phpAds_used) document.phpAds_used = ',';
   phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
   
   document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
   document.write ("http://createmybb.com/adservices/adjs.php?n=" + phpAds_random);
   document.write ("&amp;what=zone:1");
   document.write ("&amp;exclude=" + document.phpAds_used);
   if (document.referrer)
      document.write ("&amp;referer=" + escape(document.referrer));
   document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://createmybb.com/adservices/adclick.php?n=ab54dbe1' target='_blank'><img src='http://createmybb.com/adservices/adview.php?what=zone:1&amp;n=ab54dbe1' border='0' alt=''></a></noscript>