Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I found that I could use the synchronous loading, in junction with the "smart iframe" Google touts, that I could rip the link out of their iframe and place it in my DOM.</p> <p>Note that I pass the same id for the dfp code to my AdjustGoogleAd method. I'm messing with the width/height attributes because we're on a responsive site.</p> <pre><code>&lt;script type='text/javascript'&gt; (function () { var useSSL = 'https:' == document.location.protocol; var src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js'; document.write('&lt;scr' + 'ipt src="' + src + '"&gt;&lt;/scr' + 'ipt&gt;'); })(); &lt;/script&gt; &lt;script type='text/javascript'&gt; googletag.defineSlot('{AD SLOT HERE}', [WIDTH, HEIGHT], 'dfp-div-id').addService(googletag.pubads()); googletag.pubads().enableSyncRendering(); googletag.pubads().enableSingleRequest(); googletag.enableServices(); $(function () { AdjustGoogleAd('dfp-div-id'); }); function AdjustGoogleAd(bannerId) { var banner = $('#' + bannerId); var contents = $('#' + bannerId + ' iframe').contents(); contents.find('a').clone().attr('id', bannerId + '_a').appendTo('#' + bannerId); var newLink = $('#' + bannerId + '_a'); newLink.siblings().remove(); newLink.find(".img_ad").removeAttr('height').removeAttr('width'); } &lt;/script&gt; </code></pre> <p>With HTML:</p> <pre><code>&lt;div id='dfp-div-id'&gt; &lt;script type='text/javascript'&gt; googletag.display('dfp-div-id'); &lt;/script&gt; &lt;/div&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload