From c0322b1aff46325a5215d2d0de9c20db49881ad0 Mon Sep 17 00:00:00 2001 From: cityTS Date: Sun, 19 Jun 2022 19:05:58 +0800 Subject: [PATCH] Modify prohibited syntax Chrome has forbidden the old writing method, and the browser will generate an error: "failed to execute'createobjecturl'on'url': overload resolution failed." --- src/FileSaver.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/FileSaver.js b/src/FileSaver.js index 5d204ae..62dd165 100644 --- a/src/FileSaver.js +++ b/src/FileSaver.js @@ -101,7 +101,9 @@ var saveAs = _global.saveAs || ( } } else { // Support blobs - a.href = URL.createObjectURL(blob) + let binaryData = [] + binaryData.push(blob) + a.href = URL.createObjectURL(new Blob(binaryData)) setTimeout(function () { URL.revokeObjectURL(a.href) }, 4E4) // 40s setTimeout(function () { click(a) }, 0) } @@ -155,7 +157,9 @@ var saveAs = _global.saveAs || ( reader.readAsDataURL(blob) } else { var URL = _global.URL || _global.webkitURL - var url = URL.createObjectURL(blob) + let binaryData = [] + binaryData.push(blob) + var url = URL.createObjectURL(new Blob(binaryData)) if (popup) popup.location = url else location.href = url popup = null // reverse-tabnabbing #460