notablemind / downloadbutton

A small component for downloading javascript generated files
http://notablemind.github.io/downloadbutton/
33 stars 7 forks source link

doesn't work with IE 11 #1

Closed Waize closed 8 months ago

Waize commented 8 years ago

Hey,

I like your work but it is not working with IE 11 :(

Can you please fix this?

Cheers, Waize

jaredly commented 8 years ago

What about it doesn't work?

Waize commented 8 years ago

If you use IE 11, the buttons doesn't trigger the download option. You click on the button and nothing happens.

m-modgil commented 7 years ago

Quite late for a reply but this worked well for me:

function saveAs(blob, filename) {
    if (navigator.appVersion.toString().indexOf('.NET') > 0) { //check if browser is IE
        if (window.navigator.msSaveOrOpenBlob) { //check if version supports msSaveOrOpenBlob
            window.navigator.msSaveOrOpenBlob(blob, filename); //launch download prompt
        }
    } else {
        var uri = URL.createObjectURL(blob);
        var link = document.createElement('a');

        if (typeof link.download === 'string') {
            document.body.appendChild(link); //Firefox requires the link to be in the body
            link.download = filename;
            link.href = uri;
            link.click();
            document.body.removeChild(link); //remove the link when done
        } else {
            location.replace(uri);
        }
    }
}
Waize commented 8 months ago

IE11 is dead :)