文件下载不要弹出空白页面的实现

 

1、导出

// 点击导出 按钮执行如下代码

var parUrl = url ? url : '/bgtCommon/exportData?menuid=' + menuid + "&agency_code=" + agency_code + "&data_type=" + menubtns.data_type
    + "&view_id=" + view_id + '&job_id=' + menubtns.job_id + "&is_current=" + menubtns.is_current;
window.open(parUrl);

效果图:

文件下载不要弹出空白页面的实现

2、导出不要打开空白页面,直接弹出文件框另存为

// 点击导出 按钮执行如下代码

var exporurl = "/bgt-basic-server/henanBsImport/expDataByColumn?menuid=" + menuid +"&view_id=" + view_id + "&agency_id=" + agency_id + '&ui_code=' + ui_code;//下载路径
exportNoNewHtml(exporurl);

function exportNoNewHtml(exporurl){
    $("body").append("<iframe   width='0'   height='0'   frameborder='0'   name='hrong'   style=\"display:none\"></iframe>");
    window.frames["hrong"].location.href=exporurl;
    sa();
    function   sa() {
        if(window.frames["hrong"].document.readyState!="complete"){
            setTimeout("sa()",   100);
        }
        else{
            window.frames["hrong"].document.execCommand('SaveAs');
        }
    }
}

 

效果图:
文件下载不要弹出空白页面的实现