Home > Web Front-end > JS Tutorial > Non-blocking dynamic loading of javascript advertising implementation code_javascript skills

Non-blocking dynamic loading of javascript advertising implementation code_javascript skills

WBOY
Release: 2016-05-16 18:16:06
Original
1203 people have browsed it
复制代码 代码如下:





广告代码最后加载



<script> <br>//ad("open",'alert("ddd")'); <br>var JSScript = { <br>inject:function (htmlId,jsCode){ <br>var script = document.createElement("script"); <br>script.text = jsCode; <br>document.getElementById(htmlId).appendChild(script); <br>}, <br>loadeing:function (url,charset,callback){ <br>var script = document.createElement("script"); <br>script.src = url; <br>script.charset = charset; <br>script.loaded= false; <br>script.onload = function(){ <br>script.loaded = true; <br>callback(); <br>}; <br>script.onreadystatechange = function(){ <br>if(!script.onloadDone && ("loaded"==script.readyState || "complete"==script.readyState)){ <br>script.onload(); <br>} <br>}; <br>document.getElementsByTagName("head")[0].appendChild(script); <br>} <br>} <br>JSScript.loadeing("http://cbjs.baidu.com/js/s.js","gb2312",initAd) <br>function initAd(){ <br>JSScript.inject("open",'BAIDU_CLB_singleFillSlot("72893")'); <br>} <br></script>


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template