我正在构建一个 HTML5 移动 Web 应用程序。
它加载、初始化和构建接口。然后,用户可以使用它通过提要提取内容。所以用户正在查看的内容会发生变化,并显示在现有界面中。
我通过 DFP 投放广告 - DFP 广告管理系统...我当然不熟悉这个流程。
在头部,我运行初始化代码:
var ad1;
// THIS IS THE STRING THAT NEEDS TO CHANGE TO REFLECT DIFFERENT CONTENT ***
var adunit = '/8013/digital.first.media.test.site/Mobile/News';
googletag.cmd.push(function() {
ad1 = googletag.defineSlot( adunit, [[300, 50], [320, 50]], 'story_ad_top').setTargeting('pos',['mobile_section_top']).addService(googletag.pubads());
googletag.pubads().enableAsyncRendering();
googletag.pubads().disableInitialLoad(); //turns off rendering on initial load
googletag.enableServices();
});
然后,我可以随时通过调用来刷新广告:
googletag.pubads().refresh([ad1]);
这工作正常......除了用户正在查看不同的内容,因此在 init 上设置的 adunit 字符串不再是最新的。我需要更新那个字符串......但我找不到这样做的方法。
我有一个 JSFiddle 示例:http: //jsfiddle.net/wqMXV/3/
该示例有 3 个按钮,反映用户查看不同的内容。
任何帮助是极大的赞赏。