当url中存在#时,GPT脚本强制滚动到ad

GPT script forces scroll down to ad when # exists in url

本文关键字:脚本 滚动 ad GPT url 存在      更新时间:2023-09-26

还有其他人有这个问题吗?

当URL中存在散列时,google publisher标签强制页面在加载时向下滚动到广告,如果页面刷新,它向下滚动到广告,然后在刷新之前跳回到原始位置。

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

定义脚本:

<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>

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