回答編集履歴
1
サンプル追加
answer
CHANGED
@@ -1,3 +1,21 @@
|
|
1
1
|
同じオリジンで fetch で持ってこれるなら data uri scheme 化して、 mimetype を `application/octet-stream` に変更して `window.open` すればダウンロードできそうですけど
|
2
2
|
|
3
|
-
safari 使えないので試してはいません
|
3
|
+
safari 使えないので試してはいません
|
4
|
+
|
5
|
+
---
|
6
|
+
追記
|
7
|
+
|
8
|
+
サンプルです。
|
9
|
+
そのドメインのルートの html ファイルを保存する例です。
|
10
|
+
```javascript
|
11
|
+
fetch("/")
|
12
|
+
.then(e => e.arrayBuffer())
|
13
|
+
.then(result => {
|
14
|
+
const binary_str = Array.from(new Uint8Array(result), e => String.fromCharCode(e)).join("")
|
15
|
+
const base64 = btoa(binary_str)
|
16
|
+
const datauri = `data:application/octet-stream;base64,${base64}`
|
17
|
+
window.open(datauri)
|
18
|
+
})
|
19
|
+
```
|
20
|
+
|
21
|
+
Chrome では動きますが、safariの実行環境はないので試してません。
|