Google DFP slotRenderEnded函数在pubads().refresh([currentlot])之
Google DFP slotRenderEnded function working wrongly after pubads().refresh([currentSlot])
我使用googletag.pubads().refresh([currentAdSlot])在无限循环中滚动鼠标窗口向下,我想在刷新功能后收听'slotRenderEnded'事件。但每次当我调用刷新函数,'slotRenderEvent'触发累积。例如,在第一次调用ResendAd函数时,监听事件只工作一次。在秒调用时,监听事件工作两次并不断增加此计数。如何修复这个bug?我不明白怎么了?这是谷歌dfp api的错误还是我的代码?
function ResendAd(AdSlot,callback) {
googletag.pubads().clearTargeting();
googletag.pubads().updateCorrelator();
googletag.pubads().refresh([AdSlot]);
googletag.pubads().addEventListener('slotRenderEnded', function (event) {
console.warn('This function scope triggered multiple times.');
if (event.slot === AdSlot) {
if (!event.isEmpty) {
if (callback && typeof callback === "function") {
callback(event);
}
}
}
});
}
这是你代码中的一个bug。每次调用ResendAd时,都要添加一个事件侦听器(slotRenderEnded)。
应该在只调用一次的函数中添加事件侦听器。我不能告诉你具体在哪里,因为我无法访问你的代码
相关文章:
- sessonStorage refresh splashscreen
- Refresh iframe?
- jQuery Refresh Captcha正在重新加载页面
- AJAX/page refresh kills JS/jQuery
- angular google maps TypeError:$scope.map.control.refresh不是函数
- JavaScript: ΔURL, Refresh
- Rails 3.2 Coffeescript to Refresh Div using Ajax - 重新加载整个页面
- Javascript refresh() method
- Ajax refresh for telerik radgrid
- 防止 OnBeforeUnload() 事件在 refresh/F5 中发生
- HTTP-EQUIV="REFRESH" conflict with window.location
- Jquery .span refresh onclick
- DevExpress DateEdit refresh
- jQuery PHP gallery with page refresh
- JQuery Onload refresh iframe
- DevExpress MVC GridView refresh
- Javascript Refresh
- bootstrap multiselect on refresh创建新的multiselect元素
- Angular Refresh令牌授权问题
- Google DFP slotRenderEnded函数在pubads().refresh([currentlot])之