天天看點

js擷取目前項目根目錄

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