2011-07-29 77 views
0

我使用第一個代碼here下載文件。 如何等待(即以同步方式運行請求)或知道何時下載完成?如何等待下載完成?

Upd。好吧,看起來像我應該這樣做:

myfunction = function(url) { 
// downloading file here 

    persist.progressListener = { 
    onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) { 
     if (aStatus == STATE_STOP) { 

     } 
    } 
    } 
// once download is finished, myfunction should return result 
} 

如何myfunction可以返回結果,如果我使用監聽器?

回答

0

好的,是解決方案。

+0

不,['nsIDownloadManager.addListener')(https://developer.mozilla.org/en/nsIDownloadManager#addListener%28%29)應該是解決方案。 –

+0

@Wladimir,似乎你錯過了我的問題中的第一個鏈接 - 我不使用下載管理器。 –

+0

你不會,但我認爲'nsIWebBrowserPersist'確實 - 它主要用於保存網頁,並通過下載管理器。 –