title: Extract URL's directory from path, without file name such as "index.html"
body: <p>I am looking for plain JavaScript code (no jQuery etc.) to learn the directory path component of my currently loaded page's URL.</p>
  
  <p>For instance, if my page is loaded as "<a href="http://localhost/myapp/index.html" rel="noreferrer">http://localhost/myapp/index.html</a>", I like to end up with "<a href="http://localhost/myapp/" rel="noreferrer">http://localhost/myapp/</a>".</p>
  
  <p>I need this in order to create the path to a different file in the same location, e.g. to "<a href="http://localhost/myapp/other.html" rel="noreferrer">http://localhost/myapp/other.html</a>".</p>