I am trying to make a javascript to display ads in MediaWiki templates because it does not support javascript in its templates. What I did is surround the template in <div id=”infobox”></div> then tried to make a javascript function that outputs the ads, however it is not working. Here are two variations of the script I tried using, and neither works.
This function doesn’t display the ads.
[CODE]function addAdSense() {
var div = document.getElementById(‘infobox’);
if(!div) return;
var script = document.createElement(‘script’);
script.src = ‘<script type=”text/javascript”><!–
google_ad_client = “pub-XXXXXXXXXXXXXXXX”;
/* Infobox */
google_ad_slot = “XXXXXXXXXXXX”;
google_ad_width = 250;
google_ad_height = 250;
//–>
</script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>’;
div.appendChild(script);
}
addOnloadHook(addAdSense);
This function doesn’t let the page load at all.
[CODE]function addAdSense() {
var div = document.getElementById(‘infobox’);
if(!div) return;
google_ad_client = “pub-XXXXXXXXXXXXXXXX”;
google_ad_slot = “XXXXXXXXXXXX”;
google_ad_width = 250;
google_ad_height = 250;
var script = document.createElement(‘script’);
script.type = ‘text/javascript’;
script.src = ‘http://pagead2.googlesyndication.com/pagead/show_ads.js’;
div.appendChild(script);
}
addOnloadHook(addAdSense);
Any help is greatly appreciated.