0

I have a scenario where I open a popup window behind which some server side code generates an encrypted url for accessing a file on amazon web services. On completing the server side code I require to start downloading the file via the URL and also to close the popup window. An issue I have with this is determining when the download has completed. I'm not sure if this can be done.

If I do the following

window.location.href = myUrl;
javascript: setTimeout(window.close, 1000);

I can start the download and if it completes ok before 1 second then great, however I'd like to know when the download has completed and only close the window at that point.

Does anyone know if I can determine when the download has completed?

Thanks in advance for any help!

Rene Pot
  • 24,681
  • 7
  • 68
  • 92
SalesforceQueries
  • 319
  • 3
  • 7
  • 18
  • possible duplicate of [File download complete callback](http://stackoverflow.com/questions/12020168/file-download-complete-callback) – Joe Enos Oct 23 '14 at 20:32
  • It sounds like the popup isn't really needed. If you just need to stream the file to the client and not display it, then you could use a hidden `iframe`, as in this example: http://stackoverflow.com/a/16799531/3212415 – Troy Gizzi Oct 23 '14 at 20:42

0 Answers0