天天看点

js获取当前项目根目录

<html>
 <head>
     <script>
         location.pathname.replace(/\/[^/]+$/,\'\'); //js获取当前项目跟目录
         alert(location.pathname);
         alert(location.pathname.replace(/\/[^/]+$/,\'\'));
     </script>
 </head>
 <body>
 
 </body>
</html>