gpt4 book ai didi

javascript - 您如何在 localhost 中呈现 Google 广告单元?

转载 作者:行者123 更新时间:2023-12-03 06:56:36 27 4
gpt4 key购买 nike

根据研究,2014 年有一个先前的问题(Is Google adsense available for localhost?)建议添加:

data-adtest="on"

在测试和阅读 comments 之后该解决方案不再有效。在广告单元中:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- responsive_ad -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-####"
data-ad-slot="######"
data-ad-format="auto"
data-adtest="on"
data-full-width-responsive="true">
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

在 Chrome、Firefox 和 Safari 中进行测试后,会呈现一个白框。搜索后,我无法在产品论坛或任何网站上找到任何解决方案。如何在 localhost 中测试广告单元?

最佳答案

我也试过data-adtest="on"方法,它也对我不起作用。我发现了两种不同的测试方法:

  • 使用 占位符 ,最Google Adsense Forum Entry 建议的方式。
    e. G。这里:https://productforums.google.com/forum/#!msg/adsense/RLeUEq6na-w/i93-TFVRiHUJ
    (我自己试过了,对解决方案很满意)
  • 使用你自己的 (开发)域 此处解释:https://medium.com/@jeffersonlicet/testing-ads-on-localhost-300215b415d6 (我无法自己尝试,因为我没有域)

  • 如果您打开了开发者控制台,您会看到出现 403 错误。此处进一步解释了此错误的原因: https://www.shoutmeloud.com/adsense-403-forbidden-error.html .简而言之: Adsense 爬虫拒绝本地主机 .这就是为什么你有一个空白而不是广告。
    但如果有第三种方式,我也会很高兴听到它。

    关于javascript - 您如何在 localhost 中呈现 Google 广告单元?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54043177/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com