XMLHttpRequest脚本注入
作者:互联网
function loadScript(url){ let xhr = new XMLHttpRequest() xhr.open('get',url,true) xhr.onreadystatechange = function(){ if(xhr.readyState == 4){ if(xhr.status >= 200 && xhr.status <= 300 || xhr.status == 304){ let script = document.createElement('script') script.type = 'text/javascript' script.text = xhr.responseText document.body.appendChild(script) } } } }
标签:脚本,function,readyState,XMLHttpRequest,url,xhr,status,注入 来源: https://www.cnblogs.com/zhenjianyu/p/13695998.html