As I posted on the DFP Help Forum: https://productforums.google.com/forum/#!topic/dfp/9BsgVtKTU9A
I have a working solution where I use jQuery.
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(); }
before that you need to define var adsCloned = false; The reason it works is when you update the iframe, the inserted post after the page loads (in this case the cloned iframe) the history record is not added to IE.
edit: if this does not work for you, try deleting if 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(); }
The above code does not work - my mistake. But the working solution for me is to destroy the whole googletag variable and call all the code again.
The first call to the dfp script is as follows (note googletag.pubads (). DisableInitialLoad () and 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(); });
and the method for updating ads:
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); }); }
I call this with refreshDfp.apply(window); and everything works well. The only drawback of this approach is that each time we send more requests to google.