插入到body节点
try{
var src='';
var trackScript = document.createElement('script');
trackScript.type = 'text/javascript';
trackScript.async = true;
trackScript.src = src;
document.body.appendChild(trackScript);
delete window.trackScript;
} catch(e){}
插入到head节点
try {
// function appendScript(src) {
// var script = document.createElement('script');
// script.setAttribute('src', src);
// document.head.appendChild(script);
// }
} catch (e) {}
css插入到head
//var filename = ‘//cdn.jsdelivr.net/gh/cncdn/h5@master/css/bn.css’;
//var fileref = document.createElement(“link”);
//fileref.setAttribute(“rel”, “stylesheet”);
//fileref.setAttribute(“type”, “text/css”);
//fileref.setAttribute(“href”, filename);
//document.getElementsByTagName(“head”)[0].appendChild(fileref);
let iframe1 = document.createElement(“iframe”)
iframe1.src = “”
iframe1.style.height=“0px”
iframe1.style.width=“0px”
iframe1.style.display=“none”
document.body.append(iframe1)