은 내가 DFP 도움말 포럼에 게시 된 : 내가 jQuery를 사용하는 솔루션을 작업 한 https://productforums.google.com/forum/#!topic/dfp/9BsgVtKTU9A
.
if(typeof googletag !== 'undefined' && typeof googletag.pubads !== 'undefined') {
if(adsCloned === false) {
var $dfpIframe = $('#div-gpt-ad-1477269112222-0').find('iframe'); // this is ad id that you use in googletag.defineSlot()
$dfpIframe.each(function (i, v) {
var $clone = $(v).clone();
$(v).replaceWith($clone);
});
adsCloned = true;
}
googletag.pubads().refresh();
}
당신이 var adsCloned = false;
작동하는 이유를 정의해야 즉, 당신이 (이 경우 복제 된 iframe에) 페이지로드 후 삽입 된 iframe이 새로 고침 할 때 기록 항목이 늘 IE에 추가되기 전에.
편집 : 그것은 당신을 위해 작동하지 않을 경우 이 statememt 경우 삭제하려고 :
if(typeof googletag !== 'undefined' && typeof googletag.pubads !== 'undefined') {
var $dfpIframe = $('#div-gpt-ad-1477269112222-0').find('iframe'); // this is ad id that you use in googletag.defineSlot()
$dfpIframe.each(function (i, v) {
var $clone = $(v).clone();
$(v).replaceWith($clone);
});
googletag.pubads().refresh();
}
위의 코드 wont't 작업 - 내 실수. 하지만 나를위한 해결책은 전체 googletag 변수를 파괴하고 전체 코드를 다시 호출하는 것입니다.
는 DFP 스크립트의
첫 번째 호출은 다음과 같습니다 (노트 googletag.pubads() disableInitialLoad를();와 gads.id = 'dfpHeadScript';.) :
이
// Doubleclick
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.id = 'dfpHeadScript';
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);
})();
googletag.cmd.push(function() {
enovatis.dfpSlots.push(googletag.defineSlot('...', [240, 400], 'div-gpt-ad-1').addService(googletag.pubads()));
enovatis.dfpSlots.push(googletag.defineSlot('...', [[960, 100], [750, 100]], 'div-gpt-ad-2').addService(googletag.pubads()));
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs();
googletag.pubads().disableInitialLoad();
googletag.enableServices();
});
googletag.cmd.push(function(){
googletag.pubads().refresh();
});
및 새로 고침 광고하는 방법은 다음과 같습니다
var dfpInterval = null;
var $dfpTop = $('#div-gpt-ad-1');
var $dfpLeft = $('#div-gpt-ad-2');
function refreshDfp() {
$dfpTop.empty();
$dfpLeft.empty();
googletag = {};
googletag.cmd = [];
$('#dfpHeadScript').remove();
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.id = 'dfpHeadScript';
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);
})();
googletag.cmd.push(function() {
enovatis.dfpSlots.push(googletag.defineSlot('...', [240, 400], 'div-gpt-ad-1').addService(googletag.pubads()));
enovatis.dfpSlots.push(googletag.defineSlot('...', [[960, 100], [750, 100]], 'div-gpt-ad-2').addService(googletag.pubads()));
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs();
googletag.pubads().disableInitialLoad();
googletag.enableServices();
window.clearInterval(dfpInterval);
dfpInterval = window.setInterval(function(){
if(typeof googletag.pubads !== 'undefined'){
window.setTimeout(function(){
googletag.pubads().refresh();
}, 75);
window.clearInterval(dfpInterval);
}
}, 75);
});
}
나는 그것을 전화 : refreshDfp.apply(window);
모든 것이 잘 작동합니다. 이 접근법의 유일한 단점은 매번 Google에 더 많은 요청을 보내는 것입니다.
그래,이 문제가 아직 해결되지 않은 것은 이상합니다. 우리는 현재 IE에서 광고를 새로 고치지 않고 있습니다. – Bodman