Permission denied for clicking link in Internet Explorer 11
You cannot directly open blobs in Microsoft IE. You must use window.navigator.msSaveOrOpenBlob
. There's also msSaveBlob
if that's what you need.
$scope.download = function() { //etc... logic... var blob = new Blob([encoded], {type: 'vcf'}); //for microsoft IE if (window.navigator && window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(blob, fileName); } else { //other browsers var a = document.createElement('a'); a.style = "display:none"; a.href = URL.createObjectURL(blob); a.download = "filename.jpg"; a.click(); }}
One last thing: the previous code won't work on firefox because firefox doesn't support click()
. You can prototype
its behavior using this snippet:
HTMLElement.prototype.click = function() { var evt = this.ownerDocument.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null); this.dispatchEvent(evt);}