skip to Main Content

I am using a download method in word add-in it is working in windows and web and it is working in MacBook browsers but it is not working in MacBook office 365 word app.
this is my code

   const blobUrl = URL.createObjectURL(blob);

   var link = document.createElement("a");
   link.download = fileName;
   link.target = "_blank";
   // Construct the URI
   link.href = blobUrl;
   document.body.appendChild(link);

   setTimeout(function () {
       link.click();
       // Cleanup the DOM
       document.body.removeChild(link);
       DOWNLOAD_COMPLETED = true;
   }, 500);

2

Answers


  1. try this if it works

        function SaveToDisk(fileURL, fileName) {
    // for non-IE
    if (!window.ActiveXObject) {
        var save = document.createElement('a');
        save.href = fileURL;
        save.target = '_blank';
        save.download = fileName || 'unknown';
    
        var evt = new MouseEvent('click', {
            'view': window,
            'bubbles': true,
            'cancelable': false
        });
        save.dispatchEvent(evt);
    
        (window.URL || window.webkitURL).revokeObjectURL(save.href);
    }
    
    // for IE < 11
    else if ( !! window.ActiveXObject && document.execCommand)     {
        var _window = window.open(fileURL, '_blank');
        _window.document.close();
        _window.document.execCommand('SaveAs', true, fileName || fileURL)
        _window.close();
    }}
    
    Login or Signup to reply.
  2. use this if it works

    <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
    
    
    
            saveAs(blobUrl, fileName);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search