JS如何判断是否已经引入某个css或是js?
http://bbs.csdn.net/topics/390541081
function
isInclude(name){
var
js= /js$/i.test(name);
var
es=document.getElementsByTagName(js?
'script'
:
'link'
);
for
(
var
i=0;i<es.length;i++)
if
(es[i][js?
'src'
:
'href'
].indexOf(name)!=-1)
return
true
;
return
false
;
}
alert(isInclude(
"abc.js"
));
alert(isInclude(
"efg.css"
));