js判斷js文件有沒有引入,一般引入的js文件里面都會有函數和對象是否存在
可以通過js的typeof判斷
1.判斷對象
if(typeof jQuery.colorbox == 'undefined')
{
document.write("<script src=\"jquery.colorbox-min.js\" type=\"text/javascript\"><\/script>");
}
2.判斷函數
if(typeof("function_name")=="function")
{
alert("Function exists!");
}