我正在尝试延迟加载一些广告服务器代码...
在页面上我现在有这个:
<div class="ad">
<span>pos_1</span>
</div>
然后我浏览并拉出所有应该在页面上的广告,调用他们的 javascript 包含文件,它给了我这个可爱的混乱:
function do_ad(pos){
switch(pos){
case 'pos_1':
document.write('first ad text');
document.write('first ad more text');
//and so on for many many lines
break;
case 'pos_2':
document.write('second ad text');
document.write('second ad more text');
//and so on for many many lines
break;
}
}
然后我想用document.write
广告调用的结果替换跨度。
有没有办法让它返回本应写入页面的字符串?