Skip to content Skip to sidebar Skip to footer

Download File In Javascript Is Not Working In Chrome

below is the code function ExportToExcel() { if ($('#dateRange').val() != '') { var frm = $('#frmProjectReport').serialize(); var url =

Solution 1:

Here is the way we export an excel file using an IFRAME:

function download(src){
    var ifr = document.createElement('iframe');
    ifr.style.display = 'none';
    document.body.appendChild(ifr);
    ifr.src = src;
    ifr.onload = function(e){
        document.body.removeChild(ifr);
        ifr = null;
    };
}

It works in all browsers, and has the advantage of not popping up a window.


Solution 2:

Try the following:

function Download(url){
    try
    {
        var win = window.open(url,"DownloadWin","width=600px,height=300px,scrollbars=yes ,menubar=no,location=no,left=0,top=0");
        try
        {
            win.focus();
            win.moveTo(100, 100);
        }catch(e){/*Focus|moveTo not supported*/}
    }catch(e){/*open not supported, doubt it.*/}
}

I think it may be down to the moveTo() method as Chrome is a pure tabbed browser.

Also try check out the window.resizeTo(100,100)


Post a Comment for "Download File In Javascript Is Not Working In Chrome"