js实现导出文件

            var excelFilePath = "aa.pdf";
            var oReq = new XMLHttpRequest();
            oReq.open("GET", excelFilePath, true);
            oReq.responseType = "blob";
            oReq.onload = function (oEvent) {
                var content = oReq.response;
                var elink = document.createElement('a');
                elink.download = 'aa.pdf';
                elink.style.display = 'none';

                var blob = new Blob([content]);
                elink.href = URL.createObjectURL(blob);

                document.body.appendChild(elink);
                elink.click();

                document.body.removeChild(elink);
            };
            oReq.send();

你可能感兴趣的:(js实现导出文件)