0

私のコード

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);
                }
            })

私はpdfとしてダウンロードできますが、window .openを指定したため、別のウィンドウで開いてダウンロードします。同じウィンドウで作成するにはどうすればよいですか。通常のダウンロードと同じです。angular MVC を使用しています。

Firfoxは正常に動作していますが、Chromeでは新しいウィンドウで開いています

4

3 に答える 3

1

window.open(...)を使用する代わりに、iframe または window.location を使用できます。

// 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 に答える