Home » Javascript » javascript – window.navigator.msSaveOrOpenBlob is undefined in Office Add-in WebView Edge browser

javascript – window.navigator.msSaveOrOpenBlob is undefined in Office Add-in WebView Edge browser

Posted by: admin February 24, 2020 Leave a comment

Questions:

As per the requirement of our application, we invoke in-house API to get .pdf base64 file string.

And this .pdf base64 string will be passed to code that allows an option to download file from Office Add-in to end-user, Edge WebView is now loading Office Add-in as our Windows and Office is updated to latest one.

Code snippet is as follows:

var pdfAsDataUri = "data:application/pdf;base64," + base64FileString;
if (window.navigator.msSaveOrOpenBlob) {
// Create the Blob URL:
var buffer = convertDataURIToBinary(pdfAsDataUri);
var blob = new Blob([buffer], {
type: 'application/pdf'
});
window.navigator.msSaveOrOpenBlob(blob, "download.pdf");
} else {
window.open(pdfAsDataUri);
}

In above code snippet window.navigator.msSaveOrOpenBlob is undefined, hence we are unable to serve purpose of .pdf base64 file download option to end-user.

As window.navigator.msSaveOrOpenBlob is undefined, else part is getting executed which throws SEC7134 error with an exception as Access is denied.

And we are in blocker state for end-users who have updated their Windows and Office versions.

Also, this application was working fine, previous to updating Windows and Office versions, IE WebView was serving the purpose.

Please help with solution if anyone is facing same issue or found a solution.

Our Environment:

  • Platform [PC desktop, Mac, iOS, Office Online]: PC Desktop
  • Host [Excel, Word, PowerPoint, etc.]: Word
  • Office version number: Office 365 16.0.11929.20586 64-bit version
  • Operating System: Windows 10 1909 version
How to&Answers: