使用JavaScript插入几个Adsense插槽

使用JavaScript插入几个Adsense插槽,javascript,adsense,Javascript,Adsense,我需要使用javascript在同一页面中插入几个AdSense插槽 正如您在中所看到的,需要重写文档。使用全局vars google_ad_客户端、google_ad_插槽等编写 像这样:(感谢) window.google_ad_client=“123456789”; window.google_ad_slot=“123456789”; window.google_ad_width=200; window.google_广告高度=200; //容器是您希望插入广告的位置 var conta

我需要使用javascript在同一页面中插入几个AdSense插槽

正如您在中所看到的,需要重写文档。使用全局vars google_ad_客户端、google_ad_插槽等编写

像这样:(感谢)


window.google_ad_client=“123456789”;
window.google_ad_slot=“123456789”;
window.google_ad_width=200;
window.google_广告高度=200;
//容器是您希望插入广告的位置
var container=document.getElementById('ad_container');
var w=document.write;
document.write=函数(内容){
container.innerHTML=内容;
document.write=w;
};
var script=document.createElement('script');
script.type='text/javascript';
script.src=http://pagead2.googlesyndication.com/pagead/show_ads.js';
document.body.appendChild(脚本);
问题是:如果插槽只有一个globla变量。。。如何使用Javascript在同一页面中插入多个广告

<script>
window.google_ad_client = "123456789";
window.google_ad_slot = "123456789";
window.google_ad_width = 200;
window.google_ad_height = 200;

// container is where you want the ad to be inserted
var container = document.getElementById('ad_container');
var w = document.write;
document.write = function (content) {
    container.innerHTML = content;
    document.write = w;
};

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://pagead2.googlesyndication.com/pagead/show_ads.js';
document.body.appendChild(script);
</script>