Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Google Publisher标记路障和无限滚动_Javascript_Html_Ads_Google Publisher Tag - Fatal编程技术网

Javascript Google Publisher标记路障和无限滚动

Javascript Google Publisher标记路障和无限滚动,javascript,html,ads,google-publisher-tag,Javascript,Html,Ads,Google Publisher Tag,基于此,我尝试构建一个带有多个路障槽的示例。但似乎重新加载的广告没有正确初始化。最后,它应该像 我的插槽初始化: googletag.cmd.push(function() { adslotSkyLeft = googletag.defineSlot('/5064286/Skyscraper_Left', [120, 600], 'sky-left-ad'). setTargeting("test","infinitescroll"). addService(google

基于此,我尝试构建一个带有多个路障槽的示例。但似乎重新加载的广告没有正确初始化。最后,它应该像

我的插槽初始化:

googletag.cmd.push(function() {
    adslotSkyLeft = googletag.defineSlot('/5064286/Skyscraper_Left', [120, 600], 'sky-left-ad').
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    adslotSkyRight = googletag.defineSlot('/5064286/Skyscraper_Right', [120, 600], 'sky-right-ad').
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    adslotMrec = googletag.defineSlot('/5064286/SideBar_MREC', [300, 250], 'mrec-ad').
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    adslotLeader = googletag.defineSlot('/5064286/Leaderboards', [[970, 250], [970, 90], [728, 90]], 'leaderboard-ad').
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    googletag.pubads().enableSingleRequest();
    googletag.pubads().disableInitialLoad();
    googletag.enableServices();
});

我试图在重新加载的内容上初始化广告

googletag.cmd.push(function() {
    var adslotSkyLeftReload = googletag.defineSlot('/5064286/Skyscraper_Left', [120, 600], 'sky-left-ad-' + newId).
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    var adslotSkyRightReload = googletag.defineSlot('/5064286/Skyscraper_Right', [120, 600], 'sky-right-ad-' + newId).
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    var adslotMrecReload = googletag.defineSlot('/5064286/SideBar_MREC', [300, 250], 'mrec-ad-' + newId).
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    var adslotLeaderReload = googletag.defineSlot('/5064286/Leaderboards', [[970, 250], [970, 90], [728, 90]], 'leaderboard-ad-' + newId).
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    googletag.pubads().enableSingleRequest();

    googletag.display('sky-left-ad-' + newId);
    googletag.display('sky-right-ad-' + newId);
    googletag.display('mrec-ad-' + newId);
    googletag.display('leaderboard-ad-' + newId);

    googletag.pubads().refresh([adslotSkyLeftReload, adslotSkyRightReload, adslotMrecReload, adslotLeaderReload]);
});
因为这里有更多必要的代码,所以我当前的代码是:至少单击“更多”按钮6-8次,您可能需要允许第三方脚本(GPT JS)查看广告


谢谢大家!

您当前的代码似乎工作正常。问题是什么?重新加载内容时,广告填充不正确。表示路障不匹配、无路障、空插槽,有时所有插槽都是空的。