简体   繁体   中英

Anchor tag click method not working in internet explore 11

I want to stimulate automatic download using JavaScript.

Below is my code.

var a = document.createElement("a");
a.href = filepath;
a.download = filename;
a.click();

a.click() method is working fine with my Chrome browser but not working in IE 11/ 10 browser. Can anybody help me with this.

Edit 1 : my requirement is simple. i want create anchor tag, add file path and my new file name and Click method it will download file with new name. it is working on Chrome browser but not working on IE browser. As per my finding IE does not support download attribute with anchor tag.

the .click function must work in IE 11, you could try it here :

The main problem must be the way that you download the file. First of all, Could do you look the log in the IE console when you execute your code?

Object doesn't support this action 

Appear this error?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM