Mega Code Archive

 
Categories / JavaScript DHTML / Window Browser
 

Extracting the Directory of the Current Document

<html>  <head>  <title>Extract pathname</title>  <script type="text/javascript">  function getDirPath(URL) {      var result = unescape(URL.substring(0,(URL.lastIndexOf("/")) + 1));      return result;  }  function showDirPath(URL) {      alert(getDirPath(URL));  }  </script>  </head>  <body>  <form>  <input type="button" value="URL" onclick="showDirPath(window.location.href)" />  </form>  </body>  </html>