title: javascript site root
body: <p>I have this site that I need to find the root folder / plus the actual folder its works out of.</p>
  
  <p>My problem here is that during development i have the folder with in my local server that in turn is with in its own folder:</p>
  
  <p>Then online I then have the development site within a folder, so it can all be tested before the live production etc.</p>
  
  <p>LOCAL SERVER:
  localhost/mytestSiteA/...</p>
  
  <p>LIVE SERVER TEST FOLDER:
  www.asite.com/devbuild/....</p>
  
  <p>Now I can retrieve the root via the </p>
  
  <pre><code>    document.location.hostname 
  </code></pre>
  
  <p>But i need then to add the folder name after this so that I can load in content etc when in developement mode.</p>
  
  <p>LOCAL SERVER</p>
  
  <pre><code> document.location.hostname + '/mytestSiteA/'
  </code></pre>
  
  <p>LIVE TEST SITE</p>
  
  <pre><code> document.location.hostname + '/devbuild/'
  </code></pre>
  
  <p>But my issue is, is there an easy way to gain this inner folder rather than setting up variables determined on whether in local dev, live dev or live mode, as can be a pain, and would be nice to gain the current inner folder dynamically rather that manually changing etc so that I can add my paths correctly.</p>
  
  <p>Also would help as if I have a folder within this that also loads in js script it can obtain its full path.</p>
  
  <p>LOCAL SERVER:
  localhost/mytestSiteA/subsection/...</p>
  
  <p>LIVE SERVER TEST FOLDER:
  www.asite.com/devbuild/subsection/...</p>
  
  <p>I hope I have made this as easy to understand and put across.
  Si</p>