因此,我使用谷歌提供的默认系统,每30秒在我的ajax主题网站上刷新您的广告。当我使用adblock广告时,我可以看到网页上的广告计数更新,因此它会刷新,但由于某种原因,它们根本不会在页面上显示。
<script>
// Load GPT asynchronously
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement("script");
gads.async = true;
gads.type = "text/javascript";
var useSSL = "https:" == document.location.protocol;
gads.src = (useSSL ? "https:" : "http:") +
"//www.googletagservices.com/tag/js/gpt.js";
var node = document.getElementsByTagName("script")[0];
node.parentNode.insertBefore(gads, node);
})();
</script>
<script>
googletag.cmd.push(function() {
// Define the ad slot
var slot1 = googletag.defineSlot("/6931143405/Sound", [728, 90], "leaderboard").
setTargeting("Sound", "refresh").
addService(googletag.pubads());
// Start ad fetching
googletag.enableServices();
googletag.display("leaderboard");
// Set timer to refresh slot every 10 seconds
setInterval(function(){googletag.pubads().refresh([slot1]);}, 10000);
});
</script>
使用上面的javascript,我几乎可以肯定,如果使用下面的div,它应该刷新广告或者至少在div中显示广告。
<center><div id="leaderboard" style="width:728px; height:90px;"></div></center>
它说的地方
defineSlot("/XXXX/sound"
XXXX应更改为
data-ad-slot="XXXX"
google中的这一行显示默认代码是否正确?
答案 0 :(得分:1)
我发现您的代码没有任何问题,广告正在调用并刷新,但调用的网址失败(404)。您确定您的网络ID是否正确?可能这个标签组合是速率有限的吗?
http://pubads.g.doubleclick.net/gampad/ads?gdfp_req=1&correlator=2597499592245248&output=json_html&callback=callbackProxy&impl=fif&fif_to=1&sfv=1-0-2&iu=%2F6931143405%2FSound&sz=728x90&scp=Sound%3Drefresh&eri=1&cookie_enabled=1&lmt=1426955251&dt=1426955251200&cc=100&frm=20&biw=1869&bih=495&oid=3&adx=496&ady=1254&adk=1526223150&gut=v2&ifi=37&u_tz=-240&u_his=9&u_java=true&u_h=1080&u_w=1920&u_ah=1050&u_aw=1920&u_cd=24&u_nplug=10&u_nmime=52&u_sd=1&flash=17.0.0&url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F27495188%2Fgoogle-ads-are-not-refreshing&ref=http%3A%2F%2Fstackoverflow.com%2Fsearch%3Ftab%3Dnewest%26q%3D%255bjavascript%255d%2520googletag&vrg=58&vrp=58&ga_vid=953776431.1420416155&ga_sid=1426954906&ga_hid=728666356