title: How to download doc, docx files with left click jquery or javascript
body: <p>How can i set left mouse click to save the doc (docx) document to my computer? At this moment its only opening doc file in a browser, i want to prevent that. How's that can be done?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function SaveAsMe() {
          e.preventDefault(); // prevent event onclick
          document.execCommand('SaveAs');
      }
  &lt;/script&gt;
  
  &lt;a href="sites/mydoc.doc" onclick="SaveAsMe()"&gt;download doc file&lt;/a&gt;
  </code></pre>
  
  <p>The code above is not working - still opening that doc file in a browser...
  Thanks in advance.</p>
  
  <p>i can set that on my test.php page:</p>
  
  <pre><code>header("Content-Type: application/vnd.ms-word; charset=windows-1251");
  header("Content-Disposition: attachment; filename=".$node-&gt;field_book[0]['filename'].".doc");
  </code></pre>
  
  <p>but then when i load test.php it always asks me to save that file... how can i make to work that only for links that leading to doc||docx files?</p>