undaunted
undaunted

Reputation: 55

Uncaught Error: Cannot find a responsive size for a container of width=0px and data-ad-format=auto

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.

Upvotes: 2

Views: 3392

Answers (6)

Roman Karpovich
Roman Karpovich

Reputation: 1

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

Upvotes: 0

lk.
lk.

Reputation: 101

The correct solution is:

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

But you still have to remove that function from the code generated by Google.

Upvotes: 0

JakubRimal
JakubRimal

Reputation: 71

Better way than using of timeout is using of window.onload:

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

Upvotes: 3

Floyd
Floyd

Reputation: 1

set enclosed < div > or page element css property width to 100%

example .place{width:100%}

avoid {width:auto}

Upvotes: 0

Qing
Qing

Reputation: 3079

For others who get this error

window.setTimeout(function(){
  (adsbygoogle = window.adsbygoogle || []).push({});
}, 200);

init ad after page loaded.

Upvotes: 3

undaunted
undaunted

Reputation: 55

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.

Upvotes: 1

Related Questions