开发者

How do you know when a download has started from JavaScript?

Basically, I would like to wait for the IE save dialog box to open up, and then run the next line of JavaScript.

Something like:

`window.open(URL,"_self",...);`

window.alert("save dialog started");

Can this be done? Thanks

Grae

I came up with this:

              var iframe = document.getElementById("dFrameID");
              if(iframe.readyState=='complete')
                 window.close();

else wait and call this again.

Seems to work fine.

开发者_如何转开发This is IE solution only. Good luck with FF.


Javascript and the browser do not interact on this level.


I haven't tested this, but you may be able to use setTimeout(...) to get there. I have used it (only in IE) to wait until a print preview dialog had been closed.

The trick would be to wait in a loop (say five times) with enough time between those five loops to guarantee that the save dialog would have appeared. Once the dialog appears, all javascript processing should freeze. Then, when the box is closed, the javascript would start up again, and your setTimeout handler would execute.

Again, I have no idea whether this will actually work, and it would probably be different based on the browser you're using. It is also complicated by the likelyhood that your download window and alert window would be separate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜