Thursday, January 25, 2024

Print Preview Vanilla JS

 function printPreview(title) {
    var printWindow = window.open("", "_blank");
    var tableContent = document.getElementById("datatable_preview").outerHTML;
    printWindow.document.write(
        `<html><head><title>${title}</title></head><body>`
    );
    printWindow.document.write(`<h1>${title}</h1>`);
    printWindow.document.write(tableContent);
    printWindow.document.write("</body></html>");

    printWindow.document.close();
    printWindow.print();
    printWindow.close();
}

No comments:

Post a Comment

Set Cookie dan Remove Cookie dengan php vanilla.js

< html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta name = "viewport...