1 window.onload = function() 2 { 3 var al = document.getElementsByTagName("script"); 4 var new_element=document.createElement("script"); 5 var joine = [] 6 for(var i = 0; i<al.length; i++) 7 { 8 joine.push(al[i].getAttribute("src")); 9 } 10 var ajoine = joine.join(","); 11 console.log(ajoine); 12 if(IndexDemo(ajoine,‘jquery.min.js‘)>0) 13 { 14 console.log(‘1‘); 15 //alert(1); 16 }else{ 17 console.log(‘2‘); 18 var new_element=document.createElement("script"); 19 new_element.setAttribute("type","text/javascript"); 20 new_element.setAttribute("src","/static/js/jquery-1.5.1/jquery.min.js");// 在这里引入了a.js 21 document.body.appendChild(new_element); 22 //alert(2); 23 } 24 } 25 26 function IndexDemo(str1,str2){ 27 var list = str1 28 var s = list.indexOf(str2); 29 return(s); 30 }
IndexDemo() 方法查询字符.
var ajoine = joine.join(","); 方法 数组转字符串. 可修改参数去实现自己的判断效果.
时间: 2024-10-13 04:31:30