如果有一个路径是写错的并且这个路径是写在前面,那么相关的css文件你就别想引进来了
<script language="javascript" type="text/javascript" src="My97DatePicker2WdatePicker.js"></script> <script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script> <script> var X = window,M = "document", C = "getElementsByTagName"; //获取wdatepicker.js的路径 function J() { //window['document']['getElementsByTagName']结果是document.getElementsByTagName方法 var _, A, $ = X[M][C]("script"); for ( var B = 0; B < $.length; B++) { _ = $[B].getAttribute("src") || ""; //比方My97DatePicker2WdatePicker.js //_等于My97DatePicker2 _ = _.substr(0, _.toLowerCase().indexOf("wdatepicker.js")); A = _.lastIndexOf("/");//A>0 if (A > 0)//这里总觉得不够严谨,如果A<0并且if(_)等于true,那么这个路径肯定就是错误的 _ = _.substring(0, A + 1); if (_) break } return _ } console.log(J()); </script>