作者fr730149 ()
看板Ajax
标题Re: [问题] 下载提示视窗
时间Wed Feb 1 11:32:32 2012
在网路上找到另一篇教学文
http://blog.roodo.com/cat1020/archives/14908615.html
该篇是针对IE,我修改其内容,并结合上篇所PO的程式码(针对firefox):
function eeajax(data) {
//开启汇出档案loading
$.blockUI();
if($.browser.msie) {
//启动汇出档案,关闭loading(For IE)
var inputs = "";
$.each(data.split('&'), function () {
var pair = this.split('=');
inputs += "<input type='hidden' name='" + pair[0] + "' value='"
+ pair[1] + "' />";
});
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
var frame = iframe.contentWindow.document;
frame.writeln("<form id='form1' action='/StatisticClass/Export'
method='post'>" + inputs + "</form>");
frame.getElementById("form1").submit();
$(frame).one("readystatechange", function () {
if (document.readyState == "complete") { $.unblockUI(); } });
}
else if($.browser.mozilla)
{
//启动汇出档案,关闭loading(For FireFox)
var iframe = document.createElement("iframe");
iframe.src = "/StatisticClass/Export?" + data;
document.body.appendChild(iframe);
if (iframe.attachEvent) {
iframe.attachEvent("onload", function () { $.unblockUI(); });
} else {
iframe.onload = function () { $.unblockUI(); };
}
}
}
由於小弟功力有限,无法合并两个程式码,故使用 if 条件式判断浏览器…
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.125.235.184