title: Java Script to get localhost+htdocs folder
body: <p>I have following url to be build,</p>
  
  <pre><code>http://localhost/myweb/cart/index.php
  </code></pre>
  
  <p>I want to get the <code>http://localhost/myweb/</code> bit build dynamically. </p>
  
  <p>To do that on my live web site which is <a href="http://www.myweb.com/cart/index.php" rel="nofollow">http://www.myweb.com/cart/index.php</a> I can use the following JavaScript code,</p>
  
  <pre><code>var http = location.protocol;
  var slashes = http.concat("//");
  var host = slashes.concat(window.location.hostname);
  </code></pre>
  
  <p>But how do I get my development environment to work since it has <code>http://localhost/myweb/</code>? If I run the above code it will give me <code>http://localhost/</code> only.</p>
  
  <p>Any suggestions?</p>