工作下面是代码下载文件没有在Chrome
function ExportToExcel() {
if ($("#dateRange").val() != "") {
var frm = $("#frmProjectReport").serialize();
var url = "/Reports/ProjectExcelReport?" + frm;
Download(url);
}
}
function Download(url) {
alert(url);
//var win = window.open(url, "DownloadWin", "resizable=0,status=0,toolbar=0,width=600px,height=300px");
var win = window.open(url, "DownloadWin", "width=600px,height=300px,scrollbars=yes ,menubar=no,location=no,left=0,top=0")
win.focus();
win.moveTo(100, 100);
}
它除了铬所有浏览器的工作。
我用框架也如下面的代码,但它在海量数据的情况下简化版,工作..
function Download(url) {
try {
$("#fileIframe").html("");
var iframe = $('<iframe name="postframe" id="postframe" class="hidden" frameBorder="0" src="about:none" />');
$('#fileIframe').append(iframe);
$('#frmProjectReport').attr("action", url);
$('#frmProjectReport').attr("method", "post")
$('#frmProjectReport').attr("target", "postframe")
$('#frmProjectReport').submit();
//win = window.open(url, "DownloadWin", "width=600px,height=300px,scrollbars=yes ,menubar=no,location=no,left=0,top=0")
//win.focus();
//win.moveTo(100, 100);
}
catch (e) {
alert(e)
}
}
你是否检查过弹出式窗口拦截器? – sheeks06 2010-09-21 06:24:48
铬中发生了什么?如果窗口没有打开,那么可能是因为弹出窗口阻止程序。 – VinayC 2010-09-21 06:26:07
你做了...代码在所有浏览器中工作,除了chorme。 – 2010-09-21 06:26:47