2

I have a modal dialog which contain form and hidden iframe to which form is submitted. The result of submission is file to download. I need to close modal dialog as soon as download dialog is opened i.e. file is ready. I was trying to catch 'onreadystatechange' event of iframe, but after submit call changing state to 'complete' it does not trigger 'onreadystatechange' event.

Eventually, i use window.setInterval which monitoring readyState of iframe and close modal dialog when its state == 'complete'.

the solution that using window.setInterval seems not professional to me and I am looking for better solution, I saw solution with cookies but I can't use cookies in my application.

Any help will be appreciated!

yan
  • 149
  • 3
  • 11
  • Possible duplicate of http://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download – m0sa Mar 08 '11 at 13:50
  • @yan Did you ever see a FF solution for the same problem? – GC_ Feb 14 '12 at 15:21

2 Answers2

2

There is nothing wrong or unprofessional in using window.setInterval().

m0sa
  • 10,712
  • 4
  • 44
  • 91
  • Thank you very much for the quick response!!!!! Is javascript you provided should be in iframe body? – yan Mar 08 '11 at 11:29
  • I have modified the answer. You should accept the answer if it solved your problem – m0sa Mar 08 '11 at 12:13
  • Hi, i don't want to call parent method my iframe is hidden and doesn't load page it used to submit the form without refresh the page. I use it to download file and want to close modal dialog as file is downloaded. Sorry for misunderstanding and thank you again. – yan Mar 08 '11 at 13:43
  • Sorry, I misunderstood your question. – m0sa Mar 08 '11 at 13:50
0

 function Close_Popup() {
        $(".modal-backdrop").remove();
        $('#div_Popup1').modal('hide');
        $(".modal-backdrop fade in").remove();
    }

Call this function on OnClientClick="Close_div_Popup1_Popup();"