title: Javascript window.open docx file / how to close window?
body: <p>I try to open a doc/docx file in Word from html link, but I would like to avoid opening a new browser window.</p>
  
  <p>1st try : </p>
  
  <pre><code>mywin=window.open("filename.docx","viewer"); 
  </code></pre>
  
  <p><strong>Works fine, but opens a new "viewer" window.</strong></p>
  
  <p>2nd try :</p>
  
  <pre><code>mywin=window.open("filename.docx","_self"); 
  </code></pre>
  
  <p><strong>Does nothing (tested in Safari Mac)</strong></p>
  
  <p>3nd try : </p>
  
  <pre><code>mywin=window.open("filename.docx","viewer"); 
  mywin.close();
  </code></pre>
  
  <p><strong>Generates an error (closes the window before it is fully loaded)</strong></p>
  
  <p>4th try :</p>
  
  <pre><code>        mywin=window.open("filename.docx","viewer"); 
          mywin.onload = function () {
              alert("All done!");
          }
  </code></pre>
  
  <p><strong>My alert is never shown</strong></p>
  
  <p>Expected result :</p>
  
  <ul>
  <li>Word launched (this works)</li>
  <li>File opened in Word (this works with target=viewer or _blank)</li>
  <li>No child browser window </li>
  </ul>
  
  <p>Any idea for me ?</p>
  
  <p>Test link (echo never shows up) : </p>
  
  <p><a href="https://jsfiddle.net/1ddqhu2d/" rel="nofollow">https://jsfiddle.net/1ddqhu2d/</a></p>
  
  <p>Thanks a lot !</p>
  
  <p>Phil</p>