Reputation: 2962
Hi any one have idea about how to open an blob object in IE new Tab
var blob = base64toBlob(blobresponse);
if (blob) {
if (window.navigator &&
window.navigator.msSaveOrOpenBlob) {
var a = document.createElement("a");
document.body.appendChild(a);
a.href = window.URL.createObjectURL(blob);
a.target = "_blank"
a.download = "test.pdf";
a.click();
} else {
var objectUrl = URL
.createObjectURL(blob);
window
.open(objectUrl);
}
}
Upvotes: 1
Views: 11015
Reputation: 8689
As far I know, IE has a problem with opening blob URL in new tab. But you can force it to download.
window.navigator.msSaveOrOpenBlob(blob , 'test.pdf');
But if you want to view PDF in IE, you can try to use pdf.js (link)
Upvotes: 1
Reputation: 1
you can do it using iframe
var blob = base64toBlob(blobresponse);
if (blob) {
var tab = window.open();
var objectUrl = URL.createObjectURL(blob);
if (window.navigator &&
window.navigator.msSaveOrOpenBlob) { // for IE
var iframe= document.createElement("iframe");
tab.document.body.appendChild(iframe);
iframe.src = objectUrl;
iframe.setAttribute("style","width:100%;height:100%");
} else { // for Chrome
tab.location.href = objectUrl;
}
}
Upvotes: 0