views:

67

answers:

3

We have multiple websites under different domains that need to receive our banner ads. We have a server app, in PHP, that returns the HTML for a randomly-generated banner ad. Out of concern for the client side, I don't want to use an iframe nor do I want to include the jquery library because of the weight - I also do not want to duplicate code across all the domains. Any other way to do this? Maybe there is a way to do this with mod rewrite or a web service? Anyone solve a similar problem?

Thanks

A: 

You don't need to use jQuery to deliever banner ads. You can use pure javascript. This is how Google ads works, and how open source options like OpenX Ad Server too. You could even load the javascript from a php file where you can perform logic against your database of banners if you so choose.

I solved this problem a few months back by using OpenX Ad Server rather than developing my own solution. I've been thoroughly pleased with the product since then.

Jonathan Sampson
A: 

I see 3 ways to go for you:

  • Use pure javascript: no need for jquery or other libraries. Use the XMLHTTPRequest as our fathers did to include the ad. Might be the smoothest solution, but only works (obviously) with activated javascript.
  • Include the banner on the serverside: if the websites that include the banner are controlled by you, you could include the banners on the server side by requesting them from the banner server via curl etc. Not a good idea though, cause you raise the page load time which is never a good idea. Might be a nice workaround for some problems like banner blocking from McAffee and co.
  • Use an (sigh) IFrame. It simply is a good solution for your use case, like it or not.

Other (more complicated) solutions might not be a good idea in terms of the trade-off between development time and the actual gain by avoiding iframes and javascript...

Steffen Müller
The problem with AJAX in this case is the cross-site security issue whereby I cannot make an AJAX call from any client residing on a different domain than the delivery engine, which in this case is a PHP script that returns the HTML. Any way around that?
Slinky
I just used document.write(), generated by the banner generation script
Slinky
A: 

I ended up using javascript's document.write('banner html here'),generated by PHP. The client-side code is just: <script src="http://www.homesite.com/ads" type="text/javascript"></script> which is rewritten to my banner script which outputs the html in a document.write(), followed by a document.close()

Slinky