IE8 window.open 導出excel文件問題

用window.open(url)的方式來導出excel表格在FF下沒有任何問題,只要把站點設置成信任就可以了

但是在IE8下面就不行,當新打開一個窗口後你點downfile,他就沒反應了。因爲他已經攔截了第一次的請求所以你的發兩次請求。

解決方法如下:

public void exportToExcel(ActionEvent event){
	String url = "frameset?__format=xls&__report=reports%2FRateCard%2FexportRateCard.rptdesign&__id=birtViewer&__masterpage=true&__fittopage=false&__pagebreakonly=false&__asattachment=true&__overwrite=true&ratecard="+this.rateCardDbId;
	JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(), "var w = window.open('"+url+"','_blank'); w.location.href = '"+ url + "';"); 
	}

 如果用javascript就是:

function export(url){
  var w  = window.open(url,'_blank');
  w.location.href = url;
}

 這樣就能解決IE8 攔截打開excel文件的請求了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章