.click () Denying Access in IE11

When trying to call .click() anchor tag on auto click URL. The code works fine in all browsers except Internet Explorer v11 .

Any help would be appreciated.

 var strContent = "a,b,c\n1,2,3\n"; var HTML_APS = strContent; var data = new Blob([HTML_APS]); var temp_link = document.createElement('a'); temp_link.href = URL.createObjectURL(data); temp_link.download = "report_html.htm"; temp_link.type = "text/html"; temp_link.style = "display:none"; document.body.appendChild(temp_link); if (confirm("Press a button!") == true) { temp_link.click(); temp_link.remove(); } 

here is fiddle .

+4
source share
3 answers

For IE you can use navigator.msSaveOrOpenBlob

therefore, cross browser, the code will be

 var strContent = "a,b,c\n1,2,3\n"; var HTML_APS = strContent; var data = new Blob([HTML_APS]); if (confirm("Press a button!") == true) { if (navigator.msSaveOrOpenBlob) { navigator.msSaveOrOpenBlob(data, "report_html.htm"); } else { var temp_link = document.createElement('a'); temp_link.href = URL.createObjectURL(data); temp_link.download = "report_html.htm"; temp_link.type = "text/html"; document.body.appendChild(temp_link); temp_link.click(); temp_link.remove(); } } 
+9
source

When using the anchor download attribute, this means that the browser should load the anchor point resource, and not go to it.
It does not support IE11. For reference, click here.

+1
source

Per this SO answer, the 'download' attribute was not implemented in Internet Explorer.

Download attribute not implemented in Internet Explorer.

http://caniuse.com/download

For Internet explorer, you can use the "SaveAs" command.

+1
source

Source: https://habr.com/ru/post/1271829/


All Articles