JSFiddle - React, Tailwind, and code Playground

by brysmi

JavaScript

var PurchaseOrderInfo = "1234567890~0987654321~VUETURA";

function PoDownload(filename, text) {
    var pom = document.createElement('a');
    pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
    pom.setAttribute('download', filename);

    if (document.createEvent) {
        var event = document.createEvent('MouseEvents');
        event.initEvent('click', true, true);
        pom.dispatchEvent(event);
    } else {
        pom.click();
    }
}

PoDownload("PurchaseOrder.txt", PurchaseOrderInfo);