javascript - 当 url 中存在 # 时,GPT 脚本强制向下滚动到广告

标签 javascript html double-click-advertising google-publisher-tag

其他人是否也遇到过有关 Google 发布商代码的此问题?

只要网址中存在哈希,Google 发布商代码就会强制页面在加载时向下滚动到广告,如果刷新页面,它会向下滚动到广告,然后跳回之前的原始位置神清气爽。

我正在使用的脚本似乎并没有什么异常。

定义脚本:

<script type="text/javascript">
        googletag.cmd.push(function() {
            googletag
                .defineSlot('/site/test', [[300, 250]], 'gpt-ad-sto-300-250-0')
                .addService(googletag.pubads())
                .setTargeting('sec', 'Home')
                .setTargeting('pos', 'sto');

            googletag.pubads().enableSingleRequest();
            googletag.enableServices();
        });
    </script>

广告位置:

<div id="gpt-ad-sto-300-250-0">
        <script type="text/javascript">
            googletag.cmd.push(function() { googletag.display('gpt-ad-sto-300-250-0'); });
        </script>
    </div>

最佳答案

我今天遇到了完全相同的问题,我发现解决此问题的唯一解决方案是从网址中删除哈希。

关于javascript - 当 url 中存在 # 时,GPT 脚本强制向下滚动到广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33073430/

相关文章:

javascript - 如何使用 Google DFP 显示来自 ad_unit 的特定广告?

javascript - Prebid 示例在本地开发服务器上运行时不起作用

javascript - jquery 和 javascript : two load functions?

html - ie7 li under li 而不是相同的高度

javascript - 在 IE8+ 中访问对象中的唯一属性

html - 如何让 translateX 转换在 firefox 中工作?

html - z-index 不适用于 firefox 中的 flowplayer

javascript - VPAID JavaScript 广告素材

javascript - 在 Mocha 浏览器中使用多个记者?

javascript - 在javascript中使用this获取未定义的设置对象的属性值