Google Adsense错误" TagError:adsbygoogle.push()错误:availableWidth = 0没有广告位尺寸" [英] Google Adsense Error "TagError: adsbygoogle.push() error: No slot size for availableWidth=0 "

查看:284
本文介绍了Google Adsense错误" TagError:adsbygoogle.push()错误:availableWidth = 0没有广告位尺寸"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用响应式Google Ads,但不幸的是,它一直都无法正常工作,并且大多数时候它一直在返回

I'm using responsive Google Ads on my website but unfortunately it is not working all the time and most of time it is returning


TagError:adsbygoogle.push()错误:availableWidth = 0没有插槽大小

TagError: adsbygoogle.push() error: No slot size for availableWidth=0

我试图通过定义广告来解决此问题

I tried to fix the issue by defining the Ad Sizes but still the issue is not resolved yet.

.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和广告位。)

Well, this is the actual Google Adsense Google Code that I've used (for security reasons I've remove pub-id and 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>


推荐答案

我用过:

window.onload = function() {
    (adsbygoogle = window.adsbygoogle || []).push({});
}

我的网站以特殊方式加载网页,大量使用了AJAX,因此必须是这种方式。希望这对某人有帮助。

My site was loading pages in a special way, making heavy use of AJAX, so it had to be this way. Hope this helps someone.

编辑2018:我想我现在应该提一下,实现此操作的首选方法是使用 window.addEventListener('load',...),而不是 window.onload = ...

EDIT 2018: I feel like I should mention now that the preferred way to do this would be with window.addEventListener( 'load', ... ), instead of the old method of window.onload = ...

这篇关于Google Adsense错误&quot; TagError:adsbygoogle.push()错误:availableWidth = 0没有广告位尺寸&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆