• Resolved genussselektion

    (@genussselektion)


    hey, would it be possible to get a snippet that will download the csv automatically after pressing the “generate csv” button? We have a small automation. This often fails when pressing the download button “Click here”.

    would be great, thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter genussselektion

    (@genussselektion)

    Correction: “Export Now” button

    Plugin Author Atlas_Gondal

    (@atlas_gondal)

    Hi @genussselektion,

    Thanks for getting in touch. 🙂

    While it is possible, it may not be very reliable option because it tends to be hindered by browser security features, and at times, antivirus software may raise concerns about this behavior. However, I will investigate this option and confirm back over the weekend.

    In the meantime, if you provide me some background about your automation then I might suggest you a better alternative.

    Have a great rest of the day.

    Atlas

    Plugin Author Atlas_Gondal

    (@atlas_gondal)

    @genussselektion please use the following code snippet to download the file automatically. The browser might block it initially, if it does then unblock it manually.

    Place this code inside themes functions.php or use any plugin to add this javascript code to your website.

    jQuery(document).ready(function() {
        jQuery(".updated a").click(function(e) {
            e.preventDefault();
            var u = jQuery(this).attr("href");
            download(u);
        });
    
        function download(u) {
            var link = document.createElement("a");
            link.style.display = "none";
            link.href = u;
            link.target = "_blank";
    
            document.body.appendChild(link);
            link.click();
    
            document.body.removeChild(link);
        }
    
        setTimeout(function() {
            jQuery(".updated a")[0].click();
        }, 5000);
    
    });

    Hope it helps! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘automatic download after csv creation’ is closed to new replies.