根据研究,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"
方法,它对我也没有用。我发现了两种不同的测试方法:
如果您打开了开发人员控制台,您会看到有403错误。此错误的原因在此处进一步说明:https://www.shoutmeloud.com/adsense-403-forbidden-error.html。简而言之:Adsense Crawlers拒绝Localhost。多数民众赞成你为什么你有一个空白而不是广告。
但如果有第三种方式,我也很乐意听到它。