(url, name, opts)
| 120 | } |
| 121 | |
| 122 | function download(url, name, opts) { |
| 123 | var xhr = new XMLHttpRequest(); |
| 124 | xhr.open('GET', url); |
| 125 | xhr.responseType = 'blob'; |
| 126 | |
| 127 | xhr.onload = function () { |
| 128 | saveAs(xhr.response, name, opts); |
| 129 | }; |
| 130 | |
| 131 | xhr.onerror = function () { |
| 132 | console.error('could not download file'); |
| 133 | }; |
| 134 | |
| 135 | xhr.send(); |
| 136 | } |
| 137 | |
| 138 | function corsEnabled(url) { |
| 139 | var xhr = new XMLHttpRequest(); // use sync to avoid popup blocker |