title: What is the best practice for the multiple use of the same link?
body: <p>I'm trying to rationalize a website, and I have many links on it to the same document, so I want to create a JavaScript that return the URL of this document. This way, i could update the document and only have to change the URL in the function, not in all the occurrences of the link (it's a professional and internal website, with many links to official documents, that get updated often, out of my control, and each time i get to update links, i realize a while after that i forgot some, even by searching in all html files. the site is messy, was poorly written by many people, and that's why i'm trying to simplify)</p>
  
  <p>My first idea was to use <code>&lt;A href="javascript:F_link_pdf()"&gt;link&lt;/A&gt;</code>, but everyone says it's a bad practice. i still don't see why, and I don't like to use the <code>onclick</code> as it doesn't work with middle click, and i want to let users decide how they open the doc.</p>
  
  <p>Also, I want to use <code>&lt;A href="javascript:F_link_pdf()#page=39"&gt;link&lt;/A&gt;</code> to redirect to a specific page.</p>
  
  <p>on top of this, what i tried so far is not working like I intend, so i would need some help, whether to come up with a better solution, or to make this work!</p>
  
  <p>here is my js, with different versions:</p>
  
  <pre><code>function F_link_PDF() {
      // i was pretty sure this would work
      return "http://www.example.com/presentation.pdf" ;
  }
  function F_link_PDF_2() {
      document.write("http://www.example.com/presentation.pdf");
  }
  function F_link_PDF_3() {
      // i don't like this solution, as it doesn't open as user intended to
      location.href = "http://www.example.com/presentation.pdf" ;
  }
  </code></pre>
  
  <p>this example is for a pdf document, but i could also need this for html, doc, ppt...
  and finally, i started with js because i'm used to, but I could also use other languages, php, asp, if someone says it's a better option</p>
  
  <p>thanks in advance!</p>