gpt4 book ai didi

adsense - TagError : adsbygoogle. push() 错误:当我使用响应式广告时,availableWidth=0 没有插槽大小

转载 作者:行者123 更新时间:2023-12-03 13:48:22 30 4
gpt4 key购买 nike

我为 Adsense 设置了响应式广告

我收到错误消息:

未捕获的异常:TagError:adsbygoogle.push() 错误:没有可用宽度 = 0 的插槽大小

在具有此代码的每个页面上

<style type="text/css">
.adslot_2 { display:inline-block;width: 336px; height: 280px;}
@media (max-width: 336px) { .adslot_2 { width: 300px; height: 250px; } }
@media (min-width: 500px) { .adslot_2 { display: none; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle adslot_2" data-ad-client="removed for security purpose" data-ad-slot="removed for security purpose" data-ad-format="rectangle"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

我尝试篡改代码很多,但仍然得到同样的错误
请注意,我有其他具有不同代码的响应式广告单元没有显示此错误,因此我 100% 确定问题出在代码本身

我的目标是从桌面隐藏广告并在移动设备上显示

代码有什么问题?

最佳答案

Google AdSense 中有(基本上)两种不同的自适应广告单元“调整大小”方法。

  • “根据可用空间自动调整大小”data-ad-format .见 About responsive ad units页。
  • “精确的
    每屏幕宽度的广告单元尺寸”,带有 @media 查询。请参阅 How tomodify your responsive ad code 页。(您会发现有“变体”,
    此方法的不同实现。)

  • 第一个是自动的,第二个是“手动”。

    通常没有方法可以同时自动和手动,因为两者之间会有冲突,我认为如果你删除 data-ad-format="rectangle" 你的代码应该可以正常工作.

    如果这对您有用,请再次检查您的 Google AdSense 控制面板中的“我的广告”>“广告单元”页面,并确保 广告单元 ID ( data-ad-slot ) 被列为“响应式” - 这两种方法均不适用于固定尺寸的广告单元。

    关于adsense - TagError : adsbygoogle. push() 错误:当我使用响应式广告时,availableWidth=0 没有插槽大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50827616/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com