0

I have a code in angular js which downloads an excel file on clicking a button. In chrome the file download starts automatically on clicking the button. But on Microsoft Edge clicking the button displays a prompt asking the user, whether they want to open or save file. Clicking on save button in prompt shows yet another prompt with 3 buttons OPEN, OPEN FOLDER and VIEW DOWNLOADS. enter image description here

I know that edge provides settings options to disable the prompt on each download. But is there any way on edge to start download but after downloading it does not show the second prompt asking what to do, using angular js or jquery?

The code for downloading file is as follows:

                    var fileName;
                    var a = document.createElement("a");
                    document.body.appendChild(a);
                    var type = headers('Content-Type');
                    var disposition = headers('Content-Disposition');
                    if (disposition) {
                        var match = disposition.match(/.*filename=\"?([^;\"]+)\"?.*/);
                        if (match[1])
                            fileName = match[1];
                    }
                    var blob = new Blob([data], {
                            type: type
                        }),
                        url = window.URL.createObjectURL(blob);
                    if (blob.size == 0) {
                        return;
                    }
                    a.href = url;
                    a.download = fileName;

                    var isIE = false || document.documentMode || /Edge/.test(navigator.userAgent); //if browser is IE and Edge
                    if (isIE) {
                        window.blur();
                        window.navigator.msSaveOrOpenBlob(blob, fileName);
                    } else {
                        a.style = "display: none";
                        a.click();
                        window.URL.revokeObjectURL(url);
                    }
3
  • Then how is edge supposed to tell users that download is complete? Commented Aug 2, 2018 at 9:39
  • I think is the common behavior when you download any file...
    – Curlas
    Commented Aug 2, 2018 at 9:40
  • My problem is that the user of this app wants to directly open the file after downloading. He does not want to click twice before opening the downloaded file. He wants that when he clicks SAVE the file gets downloaded and then is opened. Instead of again selecting an option.
    – TGiri
    Commented Aug 2, 2018 at 9:42

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.