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"));
posted @ 2016-03-22 11:07  JIN__JIN  阅读(1912)  评论(0编辑  收藏  举报