0

I have some JavaScript that worked well in Edge version 20.x.x but since upgrading to Edge version 25.x.x it has stopped working. It should save the content of an iFrame to a file which would contain some simple text. It might be worth pointing out that it still works in IE11, 10 etc.

txtArea1.contentDocument.execCommand("SaveAs", true, "xxxx.xls");  

No error messages are thrown, it simply doesn't work.

Does anyone have any ideas why this has happened or possible workarounds?


Following on I found a solution using this:

var blobObject = new Blob([tableText]);
window.navigator.msSaveOrOpenBlob(blobObject, "download.xls.html");

I just identify IE11 or Edge and use the above and it works fine. Older versions can still use the previous code if the above fails.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Nevnev
  • 13
  • 1
  • 6

2 Answers2

0

I would prefer to create a link with a download attribute pointing to <iframe>'s src with some query string which server detects and adds this header:

Content-Disposition: attachment; filename=xxxx.xls
Václav Dajbych
  • 2,584
  • 2
  • 30
  • 45
0

Following on I found a solution using this

var blobObject = new Blob([tableText]); window.navigator.msSaveOrOpenBlob(blobObject, "download.xls.html");

I just identify IE11 or Edge and use the above and it works fine. Older versions can still use the previous code if the above fails.

Nevnev
  • 13
  • 1
  • 6