从服务器下载doc或pdf文件在IE 11和firefox中不起作用。它适用于Chrome。请帮忙。
我正在从javascript调用以下函数。
function downloadFile(urlToSend) {
var req = new XMLHttpRequest();
req.open("GET", urlToSend, true);
req.responseType = "blob";
req.onload = function (event) {
var blob = req.response;
var fileName = 'sample.doc';
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = fileName;
link.click();
};
req.send();
}