无法在 Edge 中执行 document.execCommand

Not able to execute document.execCommand in Edge

我正在尝试将一些内容导出为 .csv 文件,如下面的代码所示。

function ExportToCSV(gridContent, file_name) {
    if (detectIE()) { // Checks IE and Edge
            var IEwindow = window.open();
            IEwindow.document.write(gridContent);
            IEwindow.document.close();
            IEwindow.document.execCommand('SaveAs', true, file_name + ".csv");
     } else {
          ..... for other browsers.........
     }
  }

我遇到问题 document.execCommand,它的功能不像在 Internet Explorer 中那样,我提示对话框 window 存储 .csv 文件 internet explorer.

document.execCommand 在 Edge 中失败,我缺少什么?

function ExportToCSV(gridContent, file_name) {
if (detectIE()) { // Checks IE and Edge
     var _fileName = file_name + ".csv";
     var blob = new Blob([decodeURIComponent(encodeURI(gridContent))], {
         type: "text/csv;charset=utf-8;"
     });
     navigator.msSaveBlob(blob, _fileName);
 } else {
      ..... for other browsers.........
 }
}