var saveData = function() { var a = document.createElement("a"); var json = JSON.stringify(data), blob = new Blob([json], { type: "octet/stream" }); if (window.navigator && window.navigator.msSaveOrOpenBlob) { // for IE window.navigator.msSaveOrOpenBlob(blob, fileName); } };
var data = { t: "hello, world", d: newDate() }, fileName = "my-download.json";