如何检测doubleclick是否有AD服务?

时间:2012-07-23 23:22:26

标签: javascript detect double-click

我有一个页面有8个双击AD块,有时给定的AD参数没有AD来提供双击,有没有办法检测AD是否被服务并阻止进一步双击js加载?

{% for ad in 123|make_list %}
        <div id="ad_618_50_{{ad}}">
            <script type="text/javascript">
                    document.write("<script type='text/javascript' src='http://ad-apac.doubleclick.net/Nxxx6/adj/xxx_2011/platinum;tile=1;cp={{results.doubleclick_category_id}};lp={{results.doubleclick_region_id}};kw={{results.doubleclick_category_name}};pos=box{{ad}};sz=618x50,618x110;;ord=88xxx4590xxx98461023?'><\/script>");                        
                </script>
        </div>
{% endfor %}

1 个答案:

答案 0 :(得分:0)

好的,我已经实现了一个hack,它使用javascript来检测是否已通过doubleclick脚本添加了div,如果没有,则设置变量标志以禁止连续双击js加载

    {% for ad in 123|make_list %}
    <div id="ad_618_50_{{ad}}">
        <script type="text/javascript">
            if (typeof platinumAds === "undefined") {
                platinumAds = true;
            }
            if (platinumAds) {
                document.write("<script type='text/javascript' src='http://ad-apac.doubleclick.net/Nxxxx/adj/xxx.co.nz_2011/platinum;tile=1;cp={{results.doubleclick_category_id}};lp={{results.doubleclick_region_id}};kw={{results.doubleclick_category_name}};pos=box{{ad}};sz=618x50,618x110;;ord=xxx3014590xxx461023?'><\/script>");
                }
            </script>

        <script type="text/javascript">
            if (!$('#ad_618_50_{{ad}} > div').size()>0){
                platinumAds = false;
            }
        </script>
    </div>
    {% endfor %}