I have two chunks of code here, but only the first is functioning correctly. I'm not sure why. Does it have to do with the "download" attribute? Why? Or, is it because dl isn't correctly referncing the right object? Very confused here, been going at it for an hour or two now.
(Also, is there a way to click an object without appending it to the DOM? Guessing not.)
// WORKING
var a = document.createElement("a");
a.style = "display: none";
a.href = window.URL.createObjectURL(new Blob([this.list.join("\r\n")], {type: "octet/stream"}));
a.download = fileName;
a.click();
window.URL.revokeObjectURL(a.href);
// NOT WORKING
var dl = $('<a>',{
style: 'display: none',
download: fileName,
href: window.URL.createObjectURL(new Blob([this.list.join("\r\n")], {type: "octet/stream"}))
});
$('body').append(dl);
dl.click();
window.URL.revokeObjectURL(dl.href);