Ad Module JQuery Display Method Incompatibility
gregarios - August 8, 2009 - 04:28
| Project: | ad_flash |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
If the Ad Module settings are set to display ads using JQuery, the flash ads take over the whole window the website should be occupying. The flash ads work correctly in Javascript and RAW display modes, however. But, I prefer to use the JQuery option for ad display.

#1
Yes, I can confirm this issue.
Using JQuery can boost page load performance, but it is not compatible with Flash ads. (Flash ad is loaded in whole browser window)
#2
At the end, this is caused by the document.write on "AC_RunActiveContent.js" file, because ad_flash.module renders the ad flash as JS instead of HTML, and that's what JQuery expects.
So, to fix this, you can manually edit "theme_ad_flash_swf_render" function (ad_flash.module @ line 570) to use object and/or embed as follows:
<?php
function theme_ad_flash_swf_render($ad, $flash) {
$output = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'. $flash->width .'" height="'. $flash->height .'" id="ad'.$ad->id.'" align="middle">';
$output .= '<param name="allowScriptAccess" value="sameDomain" />';
$output .= '<param name="allowFullScreen" value="false" />';
$output .= '<param name="movie" value="' . $flash->path . '" />';
$output .= '<param name="quality" value="high" />';
$output .= '<param name="wmode" value="transparent" />';
$output .= '<param name="bgcolor" value="#000000" />';
$output .= '<embed src="' . $flash->path . '" quality="high" wmode="transparent" bgcolor="#000000" width="'. $flash->width .'" height="'. $flash->height .'" name="ad'.$ad->id.'" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
$output .= '</object>';
return $output;
}
?>
additionally, I also needed a banner rotator, so I append this code on my document ready
var banners_intID;
if (Drupal.jsEnabled) {
$(document).ready(function () {
banners_intID=setInterval('changeBanner()', 30000);
});
}
function changeBanner() {
clearInterval(banners_intID);
$('#banners div.banner').load(Drupal.settings.basePath+'sites/all/modules/ad/serve.php?m=jquery&q=1&t=&u=node&l=node',null,function (responseText, textStatus, XMLHttpRequest) {
banners_intID=setInterval('changeBanner()', 30000);
});
}
I didn't tested above code with image or text ads, but in theory must work.
Enjoy
PD:Patch attached