看板 Ajax 關於我們 聯絡資訊
在網路上找到另一篇教學文 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