检测iframe何时有响应?

时间:2010-07-20 17:04:44

标签: javascript asp.net javascript-events

我创建了一个AJAX样式文件下载(使用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#for 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();

感谢。

1 个答案:

答案 0 :(得分:0)