Hello all,

I'm tring to "force a file download", for a known file type, using only javascript.
If someone can help ...

Thank you,
Nanda.

    Have you tried

    this.location.href = 'path/to/myfile.foo';

      8 months later

      hi,

      i hope this code will help you , i tried it and it solved my problem of download :

      <body>
      <script>
      function downloadme(x){
      myTempWindow = window.open(x,'','left=10000,screenX=10000');
      myTempWindow.document.execCommand('SaveAs','null','download.pdf');
      myTempWindow.close();
      }
      </script>

      <a href=javascript:downloadme('/test.pdf');>Download this pdf</a>
      </body>

      good luck

        Write a Reply...