title: How to load common javascript files in development and on web server not using relative path?
body: <p>I am a newbie, but I have spend the last 2 days reading so may things on this, and the more I read, the more confusing it gets. Not able to find one simple instruction or example to follow, or a simple and complete answer of this very important problem.</p>
  
  <p>I simply want to include a common javascript file using <code>src=</code>. Then when I copy this tree to the server, I do not want to change anything in the code. I do not want to use relative path, since I do not want to edit the HTML file each time I change the tree layout. I want one solution that works when the tree is on the server, and also when it is locally on my PC during development.</p>
  
  <p>I am not looking for something advanced or fancy. But a very simple solution. All what I want is to be able to use a common javascript file between all the HTML files I have in my tree. </p>
  
  <p>The problem is that I do how to load it, since I can't use something like <code>$HOME</code> or <code>~</code> or an environment variable and so on, so that the same code works on my home PC, and also when I upload it to my personal web site.</p>
  
  <p>To make it simple to answer this, I show the layout at my PC:</p>
  
  <pre><code>   C:/public_html/common_files/common.js
     C:/public_html/report/index.htm
  </code></pre>
  
  <p>On the server, say my site is called <code>www.ABC.com</code>, and I see, when I ftp to it, that there the <code>public_html/</code> folder where I am supposed to put everything. So on the server, I created the same setup as above</p>
  
  <pre><code>   /public_html/common_files/common.js
     /public_html/report/index.htm
  </code></pre>
  
  <p>So far so good. Now the hard part. </p>
  
  <p>How do I load common.js from index.htm file? I do not want to use <code>src=../../common_files/common.js</code>, why? Because I might want to change the layout of the tree, and if I move my report to another level, I do not want to edit it and keep changing the path and counting "../../../../.." etc..</p>
  
  <p>I looked at many things, like <code>ResolverURL</code> but could not figure how to use it.</p>
  
  <p>I tried </p>
  
  <pre><code>  &lt;script src="&lt;%=Page.ResolveUrl("~/")%&gt;public_html/common_files/common.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But did not work. Remember, this has to work on the PC and on the server. </p>
  
  <p>Here is my current index.htm.</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  &lt;head&gt;            
     &lt;script src="../common_files/common.js"&gt;&lt;/script&gt;       
  &lt;/head&gt;
  &lt;body&gt;
          my site    
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>To explain what I am looking for, assume for the moment that $HOME works in this env., which it does not offcourse, then I could have written</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  &lt;head&gt;            
     &lt;script src="{$HOME}/common_files/common.js"&gt;&lt;/script&gt;       
  &lt;/head&gt;
  &lt;body&gt;
          my site    
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this would have worked on the PC and on the server (well, at least it would work on a PC using linux).  But the above is just an example of what I am looking for, on windows, I am not sure where $HOME is or how it is used if it is. </p>
  
  <p><strong>question</strong>: How to change the above <code>src</code> to load the <code>common.js</code> so that it works both on the PC and on the server but without using relative path?</p>
  
  <p>Please do not give my more links to see, or partial answers, or ask me to download some commercial software to do this or complicated very advanced commands. This problem is so basic and the solution should be simple to follow.</p>