我们在网站上放置广告,最简单的方法就是把JS代码,插入指定的位置,这样带了后果就是,页面按照顺序加载,偶尔一条广告代码卡住,整个页面都会卡住,给用户带来的体验是极差的。
jbMap = window.jbMap || {};
function jbViaJs(locationId) {
var _f = undefined;
var _fconv = 'jbMap[/"' + locationId + '/"]';
try {
_f = eval(_fconv);
if (_f != undefined) {
_f()
}
} catch(e) {}
}
function jbLoader(closetag) {
var jbTest = null,
jbTestPos = document.getElementsByTagName("span");
for (var i = 0; i < jbTestPos.length; i++) {
if (jbTestPos[i].className == "jbTestPos") {
jbTest = jbTestPos[i];
break
}
}
if (jbTest == null) return;
if (!closetag) {
document.write("<span id=jbTestPos_" + jbTest.id + " style=display:none>");
jbViaJs(jbTest.id);
return
}
document.write("</span>");
var real = document.getElementById("jbTestPos_" + jbTest.id);
for (var i = 0; i < real.childNodes.length; i++) {
var node = real.childNodes[i];
if (node.tagName == "SCRIPT" && /closetag/.test(node.className)) continue;
jbTest.parentNode.insertBefore(node, jbTest);
i--
}
jbTest.parentNode.removeChild(jbTest);
real.parentNode.removeChild(real)
}
jbMap['ads_one'] = function() {
document.writeln('<a href="
//www.VeVB.COm/" target="_blank">武林网</a>');
};
jbMap['ads_two'] = function() {
document.writeln('<scr'+'ipt type="text/javascript">var cpro_id = "u336546";</script><script src="
http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript"></scr'+'ipt>');
};
jbMap['ads_three'] = function() {
document.writeln('<scri'+'pt async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></scri'+'pt><ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-1247620132145618" data-ad-slot="2253650178" data-override-format="true" data-page-url="
//www.VeVB.COm"></ins><scri'+'pt>(adsbygoogle = window.adsbygoogle || []).push({});</s'+'cript>');
};