title: Using window.open() to download file, how to not remove the # in URL?
body: <p>So I am using JavaScript to download a file when an element is clicked like so:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;p onclick="download()"&gt;Click Here&lt;/p&gt;
  </code></pre>
  
  <p>JavaScript</p>
  
  <pre><code>function download(){
      window.open("file.pdf")
  }
  </code></pre>
  
  <p>Before the element is clicked, there is some #text in the URL like so: <code>folder/subfolder/index.html#text</code></p>
  
  <p>If the file opens up in the browser it replaces the current tab and when you press the back button to return to the page (such as with PDF), any #text <strong>stays</strong> in the URL. However, if the file is simply downloaded any #text gets <strong>removed</strong>.</p>
  
  <p>How can I make it so #text is not removed or how could I return it to the URL? Since the page doesn't actually reload I am unable to put code in that might detect what #text should be in the URL. What could be another workaround?</p>
  
  <p>The issue I am having is that one link downloads a file that doesn't open in the browser (not a PDF) so it causes the #text to disappear. Then, when I click on another link that does open a file in the browser (a PDF) when I click the back button, the #text is gone, but it is what allows my program to know what view to be on.</p>