【发布时间】:2016-02-01 14:26:05
【问题描述】:
我在我的网站上使用响应式 Google Ads,但很遗憾,它并非一直有效,而且大部分时间它都会返回
TagError:adsbygoogle.push() 错误:没有可用宽度=0 的槽大小
我尝试通过定义广告尺寸来解决问题,但问题仍未解决。
.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; } }
@media only screen and (min-width:800px)and (max-width:3000px) {
#topbanner {
width: 640px;
height: 90px;
}
}
嗯,这是我使用的实际 Google Adsense Google 代码(出于安全原因,我删除了 pub-id 和 ad-slot。)
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- articles(auto) -->
<ins class="adsbygoogle adslot_1"
style="display:inline-block;"
data-ad-client="ca-pub-[MY_AD_ID]"
data-ad-slot="AD_SLOT_NOS"
data-ad-format="rectangle, horizontal"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
【问题讨论】:
-
我将 AdSense 代码块放入 Angular ng-cloak 时遇到了这个问题,在我将代码块移出 ng-cloak 后问题就消失了。如果您将 adsense 代码放在一些动态生成的 html 中,请确保在执行 google 代码之前 DOM 已准备好并且可见。
-
当父容器没有有效宽度时会发生此错误 a) 由于 CSS 定位(如 absolute 或 float.OR b) 它被 display:none 隐藏。为此,您需要使用官方批准的代码更改。 1)移除高级响应标签格式属性,2)设置INS标签的宽度和高度。 GOOGLE ADSENSE ERROR - NO SLOT SIZE FOR AVAILABLEWIDTH
标签: javascript css