1Window.onload =function()2 {3 varAl = document.getElementsByTagName ("Script");4 varNew_element=document.createelement ("Script"); 5 varJoine = []6 for(vari = 0; i<al.length; i++)7 {8Joine.push (Al[i].getattribute ("src"));9 }Ten varAjoine = Joine.join (","); One Console.log (ajoine); A if(Indexdemo (Ajoine, ' jquery.min.js ') >0) - { -Console.log (' 1 '); the //alert (1); -}Else{ -Console.log (' 2 '); - varNew_element=document.createelement ("Script"); +New_element.setattribute ("type", "Text/javascript"); -New_element.setattribute ("src", "/static/js/jquery-1.5.1/jquery.min.js");//the introduction of a.js here + Document.body.appendChild (new_element); A //alert (2); at } - } - - functionIndexdemo (str1,str2) { - varList =str1 - vars =List.indexof (str2); in return(s); -}
The Indexdemo () method queries the character.
var ajoine = Joine.join (","); Method array to String.
Can modify the parameters to achieve their own judgment effect.
JS Add Validation page in the Script tab for the presence of jquery file