2010-11-23 81 views
2

我在我的网站上有一个页面,人们在此观看直播节目......我试图通过OpenX每十分钟更新一次广告横幅。广告投放刷新率

$('#ad_tag_top_left').html($('#ad_tag_top_left').html()); 

这不是做这项工作......我想知道如果有人之前做过或有任何建议。我已验证$('#ad_tag_top_left').html()确实返回下面的代码...

<!--//<![CDATA[ 
    document.MAX_ct0 ='INSERT_CLICKURL_HERE'; 

    var m3_u = (location.protocol=='https:'?'https://www.gamer-source.com/ad-server/www/delivery/ajs.php':'http://www.gamer-source.com/ad-server/www/delivery/ajs.php'); 
    var m3_r = Math.floor(Math.random()*99999999999); 

    if (!document.MAX_used) 
    document.MAX_used = ','; 

    document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u); 
    document.write ("?zoneid=62"); 
    document.write ('&amp;cb=' + m3_r); 

    if (document.MAX_used != ',') 
    document.write ("&amp;exclude=" + document.MAX_used); 

    document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : '')); 
    document.write ("&amp;loc=" + escape(window.location)); 

    if (document.referrer) 
    document.write ("&amp;referer=" + escape(document.referrer)); 

    if (document.context) 
    document.write ("&context=" + escape(document.context)); 

    if ((typeof(document.MAX_ct0) != 'undefined') && (document.MAX_ct0.substring(0,4) == 'http')) { 
    document.write ("&amp;ct0=" + escape(document.MAX_ct0)); 
    } 

    if (document.mmm_fo) 
    document.write ("&amp;mmm_fo=1"); 

    document.write ("'><\/scr"+"ipt>"); 
//]]>--> 

请问意见从执行,即使它是一个HTML注释标记内停止呢?

回答

0

document.write(只用于上面的代码片段和它所引用的广告代码中)只能在加载页面时使用,所以您的代码(无法用于执行JavaScript)无法工作。你的情况最好的解决方案(如果你不能重写剧本完全使用jQuery)是把广告代码的iframe中:

<iframe 
    src="ad_code.html" 
    width="width of your banner" 
    height="height of your banner" 
    frameBorder="0"></iframe> 

然后把这个自动刷新代码ad_code.html文件里面除了广告代码:

<script> 
setTimeout(function() { 
    window.location.reload(); 
}, 600000); 
</script> 

希望将广告代码(如果广告被点击)将不会在iframe中,但在包含窗口打开赞助商的网页。

1

OpenX提供了iFrame调用代码,它支持本地刷新。