2
我已經創建了一個Ajax風格的文件下載(使用iframe)和所有工作得很好。不過,我需要在iframe中收到的響應來檢測......請看下圖:檢測何時在iframe上有響應?
的Javascript:
function download() {
var ifrm = $('#iframedownload')[0];
ifrm.src = '/downloadfile.aspx?fileid=whatever';
ifrm.onreadystatechange = function() { // Checking
if (this.readyState == 'complete')
alert("I would really like this piece to work!");
};
}
C#爲downloadfile.aspx:
Response.AddHeader("content-disposition", "attachment; filename=\"" + zipFileName + "\"");
Response.AddHeader("Content-Length", respBytes.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(respBytes);
Response.End();
感謝。
ifrm.contentDocument.onreadystatechange適用於IE,但不適用於FireFox ...只適用於容器頁面首次呈現時... – 2010-07-20 18:24:41
閱讀本頁:http://www.atalasoft.com/cs/blogs/jake/archive /2009/06/18/events-to-expect-when-dynamically-loading-iframes-in-javascript.aspx – SLaks 2010-07-20 18:58:00