【问题标题】:I have two google ads on my website, the first one will only show if the second one is there我的网站上有两个谷歌广告,第一个只有在第二个存在时才会显示
【发布时间】:2019-10-28 03:20:32
【问题描述】:

我在我的网站顶部和主页的左侧边栏上放置了一个谷歌广告。

我尝试删除左侧边栏,但是当我这样做时,顶部广告没有出现......

我一直在查看代码以尝试查看第一个广告代码中是否存在差异或我遗漏了什么,但我找不到任何东西,我无法解释为什么它不会显示,除非我有第二个左侧添加那里。

我在显示时遇到问题的页面顶部广告如下所示:

<div align="center">
<style type="text/css">
.adslot_1 { width: 320px; height: 100px; }
@media (min-width:500px) { .adslot_1 { width: 468px; height: 60px; } }
@media (min-width:800px) { .adslot_1 { width: 728px; height: 90px; } }
</style>
<ins class="adsbygoogle adslot_1"
    style="display:inline-block;"
    data-ad-client="myGoogleID"
    data-ad-slot="adID"></ins>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
</div>

那么始终显示在左侧的广告代码如下所示:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Seek Adventure In Post Ad -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="myGoogleID"
     data-ad-slot="differentAdID"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

如果你想看到他们两个都显示,你可以去主页here

然后,如果您直接转到我的子页面之一,例如 this one。该广告不会显示,因为左侧的广告不在我的子页面上。

【问题讨论】:

  • 看起来与stackoverflow.com/questions/25095912/…相反,但这可能有助于某人找到答案
  • 这个问题是不是和网站很重有关?超过 118MB!尝试删除照片并仅显示广告。
  • 我知道它有点老了,但对我来说,首页上加载的唯一顶部广告,你解决了这个问题吗?
  • 仍在尝试解决..

标签: javascript css adsense


【解决方案1】:

评论太大了:

起初我和@AlexanderHolman 在 Firefox 67.0.4 上的评论结果相同,我只看到了顶部广告。我不得不在 FF 和 adblocker 插件中禁用内容拦截器,所以也许你遇到了类似的情况。

但后来我想我注意到了一些可以为您指明正确方向的东西: 当在主页上时,额外的&lt;ins&gt;&lt;iframe&gt; 标签会附加在末尾,这意味着您正在为主页实现一些特殊的逻辑。 我还注意到直接导航到讨论和从主页导航之间存在差异: 看看:

//Direct navigation
<div id="app" class="App affix App--discussion">

//Navigate from home page
<div id="app" class="App affix hasPane App--discussion" style="">

所以我没有浏览页面代码(有很多),但希望这能引导您找到正确的答案。

附言Javascript 代码没有被缩小,可能不是tree shaken

【讨论】:

    【解决方案2】:

    由于我不需要您网站的完整代码,因此需要一些问答环节来评估您的答案

    请执行以下步骤-

    1. 将第一个广告样式的 style="display:inline-block 更改为 style="display:block 并检查您的问题是否已解决

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多