admin管理员组

文章数量:1310502

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 remends embedding inline script tags like so:

<script language=Javascript1.1 src=".dart/ 
zonename;abr=!webtv;kw=value;sz=widthxheight;ord=value"> 
</script>

This returns 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.

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 remends embedding inline script tags like so:

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

This returns 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.

Share Improve this question edited Aug 20, 2012 at 15:59 Mike Robinson asked Oct 7, 2009 at 14:43 Mike RobinsonMike Robinson 25.2k8 gold badges63 silver badges83 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 3

I eventually resolved this using a script called writeCapture. It intercepts the document.write event on ads and lets you perform the HTML append.

The documentation on the site is great, and you can see it in action on The Daily Beast.

You should be able to replace "adj" (Ad JavaScript) with "adi" (Ad IFrame) in your script URL to get the HTML. After you make that change you can inject the script after page load by dynamically creating an iframe element, setting the source to the script URL and appending it to the DOM.

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. site.

you can also utilise /adx/ which tells doubleclick to return the ad in its original form (whether HTML / js tags etc) without wrapping it in document.write or an iframe.

But note google may not 'officially' support any issue this may cause but through experience there not many ways this can go wrong outside of your ad script

You can AJAX it in like so

<script type="text/javascript">
    var ord = Math.random();
    ord = ord*10000000000000000000;

    jQuery.ajax({
        url: "http://ad.doubleclick/adj/sitename/homepage;pos=1;ord='+ord+';sz=300x600,300x250,160x600",
        cache: false,
        dataType: "html",     
        success: function(html){
            $("#mysAd").append(html.split("'")[1]);
        }
    });
</script>

本文标签: javascriptIs there an AJAX service for doubleclick (DART)Stack Overflow