问题
I have a jquery mobile footer where I am showing a responsive adsense ad and getting the following:
Uncaught Error: Cannot find a responsive size for a container of width=0px and data-ad-format=auto
The container where I have the ad looks like:
<div data-role="footer" data-position="fixed" data-tap-toggle="false"></div>
and has dimensions of 320px by 50px.
An ad is showing in the space even though I am getting the error described above. Has anyone else seen this? Your feedback is appreciated.
回答1:
For others who get this error
window.setTimeout(function(){
(adsbygoogle = window.adsbygoogle || []).push({});
}, 200);
init ad after page loaded.
回答2:
Better way than using of timeout is using of window.onload:
window.onload = function() {
(adsbygoogle = window.adsbygoogle || []).push({});
};
回答3:
Error is caused by setting display:none to footer section. This footer sits in an overlay which is called at appropriate moments. Adsense seems to be treating it as width=0px when style for the div container is set to display:none.
回答4:
set enclosed < div > or page element css property width to 100%
example .place{width:100%}
avoid {width:auto}
回答5:
The correct solution is:
(adsbygoogle = window.adsbygoogle || []).push({})
But you still have to remove that function from the code generated by Google.
回答6:
var prev_handler = window.onload;
window.onload = function () {
if (prev_handler) {
prev_handler();
}
(adsbygoogle = window.adsbygoogle || []).push({});
};
this code works for me nice with multiple ad blocks
来源:https://stackoverflow.com/questions/21237164/uncaught-error-cannot-find-a-responsive-size-for-a-container-of-width-0px-and-d