0

my code

var url = getApplicationRoot() + '/api/dossier/report/pdfReport?reportId='+reportid;
            console.log(url);
            $http.get( url, {cache: false} )
            .success( function( data )
            {
                //success(data);
                console.log(data);
                if(success){
                    window.open( getApplicationRoot() + '/api/dossier/report/pdfReport?reportId='+reportid);
                }
            })

I am able to download as pdf ,but its opening in another window and downloading because i given window .open .How can i make in the same window .As like normal download . I am using angular MVC .

Firfox it is working fine .But in Chrome it is opening in new window

4

3 回答 3

1

只需将'_self'其作为第二个参数添加到window.open().

window.open(getApplicationRoot() + '/api/dossier/report/pdfReport?reportId=' + reportid, '_self');
于 2014-02-11T13:44:58.217 回答
1

您可以使用 iframe 或 window.location,而不是使用window.open(...) :

// iframe
var ifrm = document.getElementById(frame);
ifrm.src = getApplicationRoot() + '/api/dossier/report/pdfReport?reportId='+reportid;

// in the same window
window.location=getApplicationRoot() + '/api/dossier/report/pdfReport?reportId='+reportid;
于 2013-10-04T08:51:54.050 回答
0

我使用 Filament Group 的这个 jQuery 插件来做类似的事情: https ://github.com/filamentgroup/jQuery-File-Download

于 2013-10-04T09:21:04.997 回答