Sorry if I've not posted this support request in the right forum (if I need to re post please tell me where).
I am trying to install some javascript advertising banner tags into my drupal site. I have copied/ pasted the ad calls into blocks, and used the drupal_add_js function in template.php to reference the javascript file.
My site is a fairly straightforward Drupal installation based on Zen theme, using nice menus module for drop down navigation. There are very few other non-core modules being used by the site. The site also runs a google adsense text ad (with the javascript call pasted into a block).
However, the new advertising banner code seems to be doing strange, and unpredictable things to my site. Most of the time (perhaps 90% of the time) everything loads correctly (albeit in a slow and shakey way, sometimes).
However, sometimes there are problems. The most usual problem is that the nice menus drop down navigation bar does not appear (so the nav bar is blank), and the Google adsense ad does not appear. Sometimes the two new banner ads do not appear, while the nav bar/ google ad do. Or sometimes some other combination of these things not working. (Very occasionally other parts of the page do not load or CSS does not load - although this may be an unrelated issue). Problems occur in both IE and firefox (although not neccessarily the same ones), and they seem to occur randomly - not on specific pages or in response to specific actions.
Force refreshing the page often causes all the elements to load properly, but not always. And, the html source code for the page appears to be the same (at least for the times I have checked it), whether or not the ads/ navigation bar appear. So the problem may be that the browsers are rendering the same code inconsistently.
For some reason if I change the order of the ads, so the banner ad code is not placed at the bottom of the page, or the google adsense code is placed below the banner ads, this seems to improve the performance.
I know this advertising code is widely used on many other (non-drupal) sites, including those simultaneously running adsense ads, without problems.
Would be fantastically grateful for any help in understanding this frustrating problem - what's happening, and how I fix it, so this code does not conflict with Drupal.
I'm not a programmer so would appreciate a simple answer if possible.
I'm pasting below the ad call code for the 2 banner ads.
<script language="JavaScript" type="text/javascript">
<!--
wbds_writeTag('300X250','MIDDLE');
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
wbds_target = 'http://adserver.webads.co.uk/jserver/SITE=VCDIRECTORY.NET/AREA=VCDIRECTORY.NET_HOME';
wbds_writeTag('728X90','TOP');
//-->
</script>
<script>
<!--
wbds_firstdone=true;
//-->
</script>
And the javascript code this is referencing.
wbds_waitserver=4000;
wbds_pageid=-1;
function wbds_testserver() {
if (wbds_waitserver>0 && !wbds_firstdone) {
wbds_waitserver-=200;
setTimeout('wbds_testserver()',200);
} else if (!wbds_firstdone) {
wbds_serverup=false;
if (document.all) {
var ua=navigator.userAgent;
if (parseFloat(ua.slice(ua.indexOf('MSIE')+5))>=5) document.scripts['wbds_tag0'].src='//';
}
}
}
function wbds_writeTag(wbds_size, wbds_position) {
var rnd=Math.round(Math.random()*100000000);
if (wbds_pageid<0) wbds_pageid=Math.round(Math.random()*100000000);
if (wbds_serverup) {
document.write('<scr'+'ipt language="javascript" id="wbds_tag'+wbds_counttags+'" src="');
document.write(wbds_target+'/ADSIZE='+wbds_size+'/AAMSZ='+wbds_size+'/POSITION='+wbds_position+'/PAGEID='+wbds_pageid+'/ACC_RANDOM='+rnd+'"></scr'+'ipt>');
if (wbds_counttags++==0) setTimeout('wbds_testserver()',200);
}
}
Thanks for any help!
Comments
Timeout on testserver?
Hi!
I noticed you use a wbds_testserver, so I assume it has some limitations (no. of requests), maybe it's a problem with their server not being live all the time? Can you switch to production server and see if you get the same results?
Another thing that could be slowing it is the autoupdate feature for drupal+modules. I had this problem when hosting from .ro (same website did not have problems when on Hostgator (hosted in Texas)). The way I turned it off was using this module: http://drupal.org/project/update_notifications_disable
I would also play with admin/settings/performance, especially the css+js caching and page caching. See if it affects it in any way.
Thanks for the advice.
Thanks for the advice.
Unfortunately this does not solve the problem, although the caching had some effect on performance. Unfortunately we were never able to solve this problem completely.
However, we found that the problems dramatically reduced when the site was moved to a fast, production server. For the remaining issues, as a workaround we put the ads into iframes, to isolate the javascript from the rest of Drupal's code. This seems to be working fine.
If we ever solve this problem completely, I will post the solution here. Thanks again.