【问题标题】:Adsense responsive ad unit bug in BloggerBlogger 中的 Adsense 响应式广告单元错误
【发布时间】:2018-09-21 12:51:13
【问题描述】:

我在 Blogger 中遇到 adsense 的自适应广告问题
我按照 AdSense 帮助的说明操作
我使用此代码仅在桌面视图上显示广告:

<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
问题是,由于某种原因,当我嵌入代码时,在我保存并重新检查代码后,它会乘以代码末尾的扩展名
在我保存并重新检查后,它会将&lt;/script&gt; 的结尾加倍为 ‎&lt;/script&gt;‎‎&lt;/script&gt;‎
例如,这是我保存并重新检查后它显示代码的方式:

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

为什么会这样?

【问题讨论】:

    标签: blogger adsense


    【解决方案1】:

    问题在于 AdSense 帮助页面的希伯来语版本示例代码末尾的结束脚本标记中存在隐藏的 Unicode 字符 &amp;lrm;。这会导致 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

    【讨论】:

    • 哇,你太棒了,我已经花了好几个小时试图解决这个问题!非常感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 2018-01-24
    • 2016-04-20
    • 2016-09-25
    • 1970-01-01
    • 1970-01-01
    • 2013-12-18
    • 2014-11-22
    • 2013-09-10
    相关资源
    最近更新 更多