我的网站上有一个人们观看直播的网页...我正在尝试每隔十分钟通过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 ('&cb=' + m3_r);
if (document.MAX_used != ',')
document.write ("&exclude=" + document.MAX_used);
document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
document.write ("&loc=" + escape(window.location));
if (document.referrer)
document.write ("&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 ("&ct0=" + escape(document.MAX_ct0));
}
if (document.mmm_fo)
document.write ("&mmm_fo=1");
document.write ("'><\/scr"+"ipt>");
//]]>-->
注释是否会阻止它执行,即使它在HTML注释标记内?
答案 0 :(得分:1)
OpenX提供iFrame调用代码,它本身支持刷新。
答案 1 :(得分: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中,而是在包含的窗口中。