0

I am building a web application (PWA) using Javascript. I want the application to automatically open downloaded files, such as PDF, DOCX, etc., in an external standard application such as Adobe Reader and Word. Is there a function in Javascript that solves my problem? At the moment, the application simply downloads the file to the device.

Unfortunately, I do not have much experience with Javascript, so I apologize if this is a stupid question.

    XHR.responseType = 'blob';
    XHR.onload = function() {
      var data = this.response;
      var a = document.createElement('a');
      a.href = window.URL.createObjectURL(data);
      a.download = fileName;
      a.dispatchEvent(new MouseEvent('click'));
    };
  • Please have a look on https://stackoverflow.com/questions/1066452/easiest-way-to-open-a-download-window-without-navigating-away-from-the-page About open tool it depends on defaults of user SO – Apetrei Ionut Jan 13 '20 at 09:11
  • Thanks for the link! It works in opera, firefox, but does not work in chrome. In chrome, normal downloads without a dialog box occur. – Павел Постников Jan 15 '20 at 04:07

0 Answers0