mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-03-17 16:02:02 +01:00
Start again
This commit is contained in:
59
vendors/jszip/documentation/examples/download-zip-file.html
vendored
Normal file
59
vendors/jszip/documentation/examples/download-zip-file.html
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: "Download the generated zip file"
|
||||
layout: default
|
||||
section: example
|
||||
---
|
||||
|
||||
<p>Tip : check the source of the page !</p>
|
||||
<h2>The FileSaver API</h2>
|
||||
<div>
|
||||
Works on firefox, chrome , opera >= 15 and IE >= 10 (but NOT in compatibility view).<br/>
|
||||
<button id="blob" class="btn btn-primary">click to download</button>
|
||||
</div>
|
||||
<h2>The data URL</h2>
|
||||
<div>
|
||||
Does not work in IE, has restrictions on the length.<br/>
|
||||
<button id="data_uri" class="btn btn-primary">click to download</button>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var zip = new JSZip();
|
||||
zip.file("Hello.txt", "Hello world\n");
|
||||
|
||||
function bindEvent(el, eventName, eventHandler) {
|
||||
if (el.addEventListener){
|
||||
// standard way
|
||||
el.addEventListener(eventName, eventHandler, false);
|
||||
} else if (el.attachEvent){
|
||||
// old IE
|
||||
el.attachEvent('on'+eventName, eventHandler);
|
||||
}
|
||||
}
|
||||
|
||||
// Blob
|
||||
var blobLink = document.getElementById('blob');
|
||||
if (JSZip.support.blob) {
|
||||
function downloadWithBlob() {
|
||||
try {
|
||||
var blob = zip.generate({type:"blob"});
|
||||
// see FileSaver.js
|
||||
saveAs(blob, "hello.zip");
|
||||
} catch(e) {
|
||||
blobLink.innerHTML += " " + e;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bindEvent(blobLink, 'click', downloadWithBlob);
|
||||
} else {
|
||||
blobLink.innerHTML += " (not supported on this browser)";
|
||||
}
|
||||
|
||||
// data URI
|
||||
function downloadWithDataURI() {
|
||||
window.location = "data:application/zip;base64," + zip.generate({type:"base64"});
|
||||
}
|
||||
var dataUriLink = document.getElementById('data_uri');
|
||||
bindEvent(dataUriLink, 'click', downloadWithDataURI);
|
||||
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user