我在 Blogger 中遇到了 Adsense 响应式广告的问题
我按照 AdSense 帮助的说明进行操作
我使用此代码仅在桌面 View 上显示广告:
<style>
@media(min-width: 961px) { .ad-test1 { width: 100%; height: 90px; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ad-test1 -->
<ins class="adsbygoogle ad-test1"
style="display:inline-block"
data-ad-client="ca-pub-ZZZZZ"
data-ad-slot="XXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
这是来自 Adsense 帮助的原始代码:
<style>
.example_responsive_1 { width: 320px; height: 100px; }
@media(min-width: 500px) { .example_responsive_1 { width: 468px; height: 60px; } }
@media(min-width: 800px) { .example_responsive_1 { width: 728px; height: 90px; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- example_responsive_1 -->
<ins class="adsbygoogle example_responsive_1"
style="display:inline-block"
data-ad-client="ca-pub-XXXXXXX11XXX9"
data-ad-slot="8XXXXX1"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
https://support.google.com/adsense/answer/6307124?hl=iw
问题是,由于某种原因,当我嵌入代码时,在我保存并重新检查代码后,它会乘以代码末尾的扩展名
它双尾
</script>
至 </script></script>
在我保存并重新检查后。例如,这是我保存并重新检查后显示代码的方式:
<style>
@media(min-width: 961px) { .ad-test1 { width: 100%; height: 90px; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ad-test1 -->
<ins class="adsbygoogle ad-test1"
style="display:inline-block"
data-ad-client="ca-pub-ZZZZZ"
data-ad-slot="XXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></script>
为什么会这样?
最佳答案
问题在于隐藏的 Unicode 字符 ‎
出现在 AdSense 帮助页面希伯来语版本示例代码末尾的结束脚本标记中。这会导致 Blogger 的 HTML 解析器假定 script
标签没有关闭,它从它自己的一端添加了一个关闭脚本标签。
要解决此问题,请使用以下代码 -
<style>
.example_responsive_1 { width: 320px; height: 100px; }
@media(min-width: 500px) { .example_responsive_1 { width: 468px; height: 60px; } }
@media(min-width: 800px) { .example_responsive_1 { width: 728px; height: 90px; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
<!-- example_responsive_1 -->
<ins class="adsbygoogle example_responsive_1"
style="display:inline-block"
data-ad-client="ca-pub-XXXXXXX11XXX9"
data-ad-slot="8XXXXX1"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
或者从 AdSense 帮助页面的英文版获取示例代码 - https://support.google.com/adsense/answer/6307124?hl=en
关于blogger - Blogger 中的 Adsense 响应式广告单元错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49778405/