2010-07-20 9 views
2

내가 (iframe을 사용) AJAX 스타일의 파일 다운로드를 생성하고 모든 것이 잘 작동합니다 ... 그러나, 나는 iframe이 응답을받은 때를 감지 할 필요가 ... 아래 참조 :iframe에 응답이있을 때 감지 중입니까?

자바 스크립트 :

downloadfile.aspx에 대한
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 번호 :

Response.AddHeader("content-disposition", "attachment; filename=\"" + zipFileName + "\""); 
Response.AddHeader("Content-Length", respBytes.Length.ToString()); 
Response.ContentType = "application/octet-stream"; 
Response.BinaryWrite(respBytes); 
Response.End(); 

감사합니다.

답변

0
+0

ifrm.contentDocument.onreadystatechange가 IE에서는 작동하지만 FireFox에서는 작동하지 않습니다 ... 컨테이너 페이지가 처음 렌더링 될 때만 작동합니다 ... –

+0

이 페이지를 읽으십시오 : http://www.atalasoft.com/cs/blogs/jake/archive /2009/06/18/events-to-expect-when-dynamically-loading-iframes-in-javascript.aspx – SLaks