异步加载js代码

异步加载js代码

function addTag(name, attributes, sync) { var el = document.createElement(name),attrName; for (attrName in attributes) { el.setAttribute(attrName, attributes[attrName]); } sync ? document.write(outerHTML(el)) : appendHead(el); } // 插入头部 function appendHead(node) { var headEl = document.getElementsByTagName("head"); headEl[0].appendChild(node) } // 将script转换一次,直接插入会出现无效效果 function outerHTML(node) { // if IE, Chrome take the internal method otherwise build one return node.outerHTML || (function (n) { var div = document.createElement(\'div\'), h; div.appendChild(n); h = div.innerHTML; div = null; return h; })(node); } addTag(\'script\', {src: \'ui/bootstrap-table/bootstrap-table.min.js?v=\'+Date.now()}, true); addTag(\'script\', {src: \'ui/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=\'+Date.now()}, true);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzdswy.html