Quantcast
Channel: VBForums - jQuery
Viewing all articles
Browse latest Browse all 58

JQuery > button > click created link

$
0
0
Hi again,

I have this working in Chrome and Firefox (although Firefox blocked direct clicking on a created link - click a span in a link tho...)
However, Edge/IE(?) runs the JS up to the JQuery trigger... and doesnt run the last bit.

Code:

function dlResultos( mimeType ){
        var al=$("#hiddenlink");
        var dt = new Date();
        var filename = ''+dt.getYear()+(dt.getMonth()+1)+dt.getDate()+dt.getHours()+dt.getMinutes()+dt.getSeconds()+"sql.txt";
    var elHtml = "";
        var obj = document.getElementById("resultoHidden");
       
        if( obj != null ) {       
                elHtml = obj.innerHTML;
                elHtml = elHtml.split("<br>").join("\r\n");
                elHtml = elHtml.split("&nbsp;").join(" ");
        }
       
        if( elHtml.length>0 ) {
                if(al.length==0){
                        al = $("<a></a>");
                        al.attr("id","hiddenlink");
                        al.css("display","none");
                        $("#btnDLR").after(al);
                        al.html($("<span></span>").text("test"));
                }
               
                al.attr('download',filename);
                al.attr('href','data:' + mimeType  +  ';charset=utf-8,' + encodeURIComponent(elHtml));
                $("#hiddenlink span").trigger('click'); // < problem is here on edge

        }else{
                alert("Nada para salvar!");
        }

}

Does Edge have a security measure to block this type of clicking ?


Note: running a Java JSP page... for the extra code not JS...

Viewing all articles
Browse latest Browse all 58

Latest Images

Trending Articles





Latest Images