4

我正在尝试在我的网站上放置一些广告,并希望在页面加载后加载它们。我们正在使用 Doubleclick DART(请不要告诉我使用 Google AdSense。我知道,但这是另一天的战斗)。Doubleclick 目前建议嵌入内联脚本标签,如下所示:

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

这将返回一个带有广告 html 的 document.write。

有谁知道通过 AJAX 调用请求广告的方法,以便只返回 HTML,从而允许我自行决定放置广告?我已经看到移动广告这样做了,但还没有找到任何网站。

4

5 回答 5

3

我最终使用名为writeCapture的脚本解决了这个问题。它拦截广告上的 document.write 事件并让您执行 HTML 附加。

网站上的文档很棒,您可以在The Daily Beast上看到它的实际效果。

于 2011-08-29T19:39:43.230 回答
3

您应该能够在脚本 URL 中将“adj”(广告 JavaScript)替换为“adi”(广告 IFrame)以获取 HTML。进行更改后,您可以在页面加载后通过动态创建 iframe 元素、将源设置为脚本 URL 并将其附加到 DOM 来注入脚本。

于 2012-09-23T21:51:15.167 回答
1

我使用 jQuery 编写了一个扩展,在页面加载后将 DoubleClick 广告注入页面。您可以在jquery-doubleclick-ads - Google Code上找到它,它目前在 www.ourbrisbane.com 网站上使用。

于 2009-10-21T06:45:29.853 回答
0

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

于 2013-04-10T06:35:32.493 回答
-1

你可以像这样AJAX它

<script type="text/javascript">
    var 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]);
        }
    });
</script>
于 2009-12-15T20:19:19.767 回答