问题描述:

I'm creating a web page dynamically with JQuery (writing HTML modules outside of the content and appending them to containers).

The problem is that Adsense doesn't seem to like that and returns "Cannot find a responsive size for a container of width=0px and data-ad-format=auto".

Here's an example code CodePen

HTML

<div class="container">

<div id="content-hook" class="row"></div>

</div>

<div id="modules" class="hidden">

<div id="content" class="col-xs-12">

A sample content

</div>

<div id="ad-unit-1" class="col-xs-12">

Ad unit goes here

</div>

</div>

JS

var modules = [

{ module: 'content', hook: 'content-hook', position: '1'},

{ module: 'ad-unit-1', hook: 'content-hook', position: '2'},

];

function byPosition(a, b) { return b.position-a.position; }

modules.sort(byPosition);

$(document).ready(function(){

$.each(modules, function(i, v){

if(v.hook != '') {

$('#' + v.module).prependTo('#' + v.hook);

}

})

});

Any ideas?

相关阅读:
Top