在 Google DFP (DoubleClick) 中,系统会为您提供一个广告代码以放入页眉,另一个用于您的正文。当我将这个给定的广告标签/代码应用到我的网站时,无论是异步还是同步,广告总是显示在 iframe 中。我想知道如何禁用 iFrame。
这是通过 DFP 生成的 header 代码:
<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
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);
})();
</script>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.defineSlot('/16569348/ad-test-1', [400, 267], 'div-gpt-ad-1362958263281- 0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
这是通过 DFP 生成的正文代码:
<!-- ad-test-1 -->
<div id='div-gpt-ad-1362958263281-0' style='width:400px; height:267px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1362958263281-0'); });
</script>
</div>
这是展示此问题的 jsFiddle(在谷歌浏览器中检查元素以查看 iframe):
同样,我想删除 iframe(当然要保留图片/广告)...任何帮助将不胜感激。 :)
最佳答案
来自 DFP 网站:link
When you are using Google Publisher Tags (GPT), your ads will automatically load into iframes.
关于javascript - 禁用 DFP/DoubleClick iFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15330619/