blogger - Blogger 中的 Adsense 响应式广告单元错误

标签 blogger adsense

我在 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 字符 &lrm;出现在 AdSense 帮助页面希伯来语版本示例代码末尾的结束脚本标记中。这会导致 Blogger 的 HTML 解析器假定 script标签没有关闭,它从它自己的一端添加了一个关闭脚本标签。

invisible unicode character

要解决此问题,请使用以下代码 -

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

相关文章:

javascript - Highlight.js 与 Blogger : can't disable auto line wrap

adsense - 如何在 SPA(单页应用程序)的路由更改时调用 AdSense 自动广告?

blogger - 如何根据浏览量对您的博文进行排序?

javascript - 如何将随机类名添加到博客模板中的元素

android - 广告合并?

angularjs - 使用 Angularjs 后,Adsense 停止显示广告

javascript - 响应式 Adwords 广告

tracking - 如何自定义 Adsense 的广告跟踪?

javascript - 滚动的在线帖子

javascript - Blogger 上的 JQuery 文档加载问题