title: HTML Conditional href
body: <p>I have a folder containing a large number of pdf files. They are named with a code of 3 digits (XXX.pdf). In that same folder, I have a index.html file, which as its name suggests, is an index for navigating in the folder and opening a specific pdf.</p>
  
  <p>As an example, when I search a specific pdf file but I don't know what's the name of the pdf. I only know its title or authors.</p>
  
  <ul>
  <li>Without that index, I have no solution to find it.</li>
  <li>With the index, the pdf are classified according to authors or titles so I can search within the index and click on the link to open the file. The index contain this line for each pdf file:</li>
  </ul>
  
  <pre class="lang-html prettyprint-override"><code>&lt;a href="001.pdf"&gt;&lt;STRONG&gt;TITLE001&lt;/STRONG&gt;&lt;/a&gt;&lt;br /&gt; Author001
  </code></pre>
  
  <p>So, this is the first configuration. I can give the entire folder to a colleague and he can open the index to search for a file as soon as he doesn't change the folder organization because the href link is relative.</p>
  
  <p>Now, I have a second configuration in which I uploaded that folder on a server on a private network. I changed the index.html with the following line:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;a href="http://personal_cloud/001.pdf"&gt;&lt;STRONG&gt;TITLE001&lt;/STRONG&gt;&lt;/a&gt;&lt;br /&gt;Author001
  </code></pre>
  
  <p>In that way if someone search a specific pdf file, he can download the index and when he click on the like in that index, it will download the correct pdf from the server.</p>
  
  <p>BUT, I would like to have both configuration working:</p>
  
  <ul>
  <li>If my colleague uses a lot that folder, he will maybe prefer to download the entire folder and the index will not work because its not a relative address anymore.</li>
  <li>If my colleague uses it occasionally, he will just download the index and it will work.</li>
  </ul>
  
  <p>Is there any solution to merge both solution and to have a conditional href attribute ?</p>
  
  <p>Allowing to use both configurations. Something like:</p>
  
  <pre class="lang-html prettyprint-override"><code>if "001.pdf" doesn't exist
     &lt;a href="http://personal_cloud/001.pdf"&gt;&lt;STRONG&gt;TITLE001&lt;/STRONG&gt;&lt;/a&gt;&lt;br /&gt;Author001
  else
     &lt;a href="001.pdf"&gt;&lt;STRONG&gt;TITLE001&lt;/STRONG&gt;&lt;/a&gt;&lt;br /&gt;Author001
  </code></pre>
  
  <p>Can someone help me with that ?</p>
  
  <p>Thanks a lot !</p>