twitter-bootstrap – Adsense响应:availableWidth = 0没有插槽
发布时间:2020-12-17 21:26:25 所属栏目:安全 来源:网络整理
导读:如何在响应式网站布局上使用谷歌adsense响应式块?让我们考虑一下这个简单的例子(用bootstrap编写): div class="container" div class="row" div class="col-sm-4 col-md-3"Menu/div div class="col-sm-8 col-md-6"Content/div div class="col-md-3 hidden-
如何在响应式网站布局上使用谷歌adsense响应式块?让我们考虑一下这个简单的例子(用bootstrap编写):
<div class="container"> <div class="row"> <div class="col-sm-4 col-md-3">Menu</div> <div class="col-sm-8 col-md-6">Content</div> <div class="col-md-3 hidden-sm hidden-xs">Column with Adsense</div> </div> </div> 因此,对于大屏幕,我们有3列布局,对于小屏幕,我们只有两列.右栏不是很重要,所以我们只是隐藏它,它包括adsense响应块,我们也隐藏它. 如果我们在小屏幕上打开此页面,则会收到错误TagError:adsbygoogle.push()错误:availableWidth = 0没有插槽大小.怎么避免这个? 理想情况下,我想重新初始化adsense块,如果窗口大小改变(在小屏幕上打开然后放大,以便第三列变得可见,应该在出现的列中触发adsense初始化),但我想现在不可能. 我试图将adsense放到固定大小的容器(它位于hidden-xs块内),它不起作用,无论如何都会出现错误. 我还尝试将响应式类添加到< ins class =“adsbygoogle hidden-xs”> …< / ins>但它也不会删除错误. 解决方法
我有同样的问题,即使我禁用了push()调用我仍然收到错误,因为谷歌仍然会在下次调用push()时发现此广告元素(针对不同的广告),
最后,只有在没有隐藏消失的div时才注入fly的JavaScript. <div id="ad-top-right-wrapper" class="hidden-xs col-sm-4 col-lg-3"> <!-- Portal top right links --> /* <ins class="adsbygoogle" style="display: block; overflow: hidden;" data-ad-test="@googleDataAdTest" data-ad-client="ca-pub-9651717958493835" data-ad-slot="5910985512" data-ad-format="link"></ins> */ <script> // Inject this ad manually when hidden-xs is not in affect (the div is visible) // Otherwise google ads will try to push it when the next .push() is called if (($("#ad-top-right-wrapper").css("display") !== "none")) { document.write("<ins class='adsbygoogle'" + " style='display: block; overflow: hidden;'" + " data-ad-test='@googleDataAdTest'" + " data-ad-client='ca-pub-9651717958493835'" + " data-ad-slot='5910985512'" + " data-ad-format='link'></ins>"); (adsbygoogle = window.adsbygoogle || []).push({}); } </script> </div> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- angularjs 2的开发中遇到的bug之二
- bootstrap-table 常用总结-树形结构(展开和折叠)
- bash – 使用groovy,你如何管道多个shell命令?
- scala – String interpolation和macro:如何获取StringCon
- angularjs – 控制isOpen in angular ui bootstrap
- 【转】ZSI + mod_wsgi
- Angular 2 Bootstrapping Options – AOT vs JIT
- scala – Python:将pandas数据框保存到镶木地板文件中
- java – 是否可以将docker与jrebel或dcevm一起使用
- 拓扑排序(AOV)---判断图中是否有环---《数据结构》严蔚敏