How to embed Adsense ads inside a Blogger.com post
Sep 3, 2007 Uncategorized
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
- Now you have to find the DIV tag that contains the id to the 'sidebar'. Normally it's after all the comments stuff. Insert BEFORE this DIV tag the following javascript code:
var nodes = document.getElementsByTagName('DIV');
var size = nodes.length;
for (var i = 0; (i
if (nodes[i].style.clear=='both') {
nodes[i].style.clear='';
}
}
And that's all folks. Test it before publishing. I have tested it in FireFox and Internet Explorer in Windows. If you can test it in Safari or Opera, please send me some feedback.
Comments, improvements and problems will be welcomed!
Update 1: A colleague sent me a CSS hack. You can find it here.
Update 2: To restrict the effect of the script to the posts avoiding the sidebars and other effects, this version modified of the script only affects the post bodies.
var nodes = document.getElementsByTagName('DIV');
var size = nodes.length;
for (var i = 0; (i
if (nodes[i].style.clear=='both') {
if(nodes[i].parentNode.className=='post-body') {
nodes[i].style.clear='';
}
}
}
Tweet One of the most annoying things of a Blogger.com blog was how difficult was to add AdSense ads in your blog. Currently this is not an issue anymore because you can add automatically AdSense ads in your page thanks to the Blogger dashboard. But if you read blogs you will realize that some blogs [...]

