1
sneezry 2014-09-17 21:52:03 +08:00
var ga = document.createElement("script");
ga.src = "//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"; document.getElementsByTagName("head")[0].appendChild(ga); var ins = document.createElement("ins"); ins.className = "adsbygoogle"; ins.style = "display:inline-block;width:970px;height:250px"; ins.setAttribute("data-ad-client", "ca-pub-9055653551438880"); ins.setAttribute("data-ad-slot", "7443996645"); document.getElementsByTagName("body")[0].appendChild(ins); (adsbygoogle = window.adsbygoogle || []).push({}); 虽然不知道楼主为啥不直接写进HTML,但是楼主的写法太尼玛凶残了…… |
2
kmvan 2014-09-17 21:58:59 +08:00
为啥要这样写,就算是 document.write ,也会堵塞页面的
|
3
acecode 2014-09-18 00:19:49 +08:00
document.write才对吧
另外 浏览器检查 script标签内容的时候看到</script>会当做脚本定义完毕 参照 h5bp 的做法,字符串里应该用这个 <\/script> |
4
hkongm 2014-09-18 08:55:42 +08:00
async或者defer下吧
另外,小声的说下,楼主是不是忘了关adb? |
5
a7898585 OP @sneezry
@hkongm @acecode @kmvan 改好了,谢谢各位 document.writeln('<script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></scr'+'ipt>' +' <!-- 970*250 -->' +' <ins class="adsbygoogle"' +' style="display:inline-block;width:970px;height:250px"' +' data-ad-client="ca-pub-9055653551438880"' +' data-ad-slot="7443996645"></ins>' +' <script>' +' (adsbygoogle = window.adsbygoogle || []).push({});' +' </scr'+'ipt>'); |
6
cdxem713 2014-09-19 09:55:22 +08:00
这写法还是够奇葩
|