title: How can I know that an iframe has finished loading?
body: <p>I used iframe to download file from my web application when a button is clicked.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    iframe = document.createElement("iframe");
      iframe.src = "Report/ExportFile.aspx";
      iframe.style.display = "none";
      document.body.appendChild(iframe);
  </code></pre>
  
  <p>I want to call a function in the parent page (the one that includes the iframe), to stop my loading animation.</p>
  
  <p>I need to know when the iframe finish loading, and the save/open dialog pops up in order to stop it.</p>
  
  <p>I tried to stop the animation inside iframe.onload = function() { //close },
  but the problem is that inside the iframe page load I have this code:</p>
  
  <pre><code>    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
      Response.AddHeader("content-disposition", "attachment;  filename=ExcelDemo.xlsx");
      Response.BinaryWrite(pck.GetAsByteArray());
      Response.Flush();
      Response.End(); 
  </code></pre>
  
  <p>so the page execution terminates.</p>
  
  <p>Does anyone have a solution how can I know that the iframe has loaded?</p>