views:

519

answers:

3

I'm trying to put some ads on my site and would like to load them after the page has loaded. We're using Doubleclick DART (please, don't tell me to use Google AdSense. I know, but that's a battle for another day). Doubleclick currently recommends embedding inline script tags like so:

<script language=Javascript1.1 src="http://ad.doubleclick.net/adj/sitename.dart/ 
zonename;abr=!webtv;kw=value;sz=widthxheight;ord=value"> 
</script>

This return a document.write with the ad html.

Does anyone know of a way to request the ads with an AJAX call so that only HTML is returned, thus allowing me to place the ads at my discretion? I've seen this done for mobile ads, but haven't found anything for websites yet.

A: 

I wrote an extension using jQuery to inject DoubleClick ads into a page after page load. You can find it at jquery-doubleclick-ads - Google Code and it is currently in use on the www.ourbrisbane.com site.

Christopher
A: 

You can AJAX it in like so

ord=Math.random(); ord=ord*10000000000000000000; jQuery.ajax({ url: "http://ad.doubleclick.net/adj/sitename/homepage;pos=1;ord='+ord+';sz=300x600,300x250,160x600", cache: false, dataType: "html", success: function(html){ $("#mysAd").append(html.split("'")[1]); } });
Todd B
A: 

@Todd B: Are you sure? I tried the method you gave, but it doesn't work - The script returns a "501 Not Implemented" message in the Net panel in Firebug. I think this is due to the cross-domain call. Have you actaully used your code? If so, what am I missin?

Thanks!

Hey - click "Add Comment" underneath the answer to add comments, instead of posting an answer. And welcome to StackOverflow!
Mike Robinson