By iframe download files, determine the download is complete

Leadership to schedule tasks, data export function, plus a wait for results.

At that time I thought, this thing can not achieve ah, because the whole is downloaded via an iframe, file the return flow back directly, no way ah js code execution

Then I thought of the iframe onload event tried it, do so ah, then the online search, I really search to, by judgment document iframe's readyState.

code show as below:

// Use iframe readyState polling timer, it is determined whether the download is completed (pop-up box or downloaded to start the download) 
    var Timer = the setInterval ( function () {
         var iframeDoc = excelIFrame.contentDocument || excelIFrame.contentWindow.document;
         // the Check IF Complete IS loading 
        IF (iframeDoc.readyState == 'Complete' || iframeDoc.readyState == 'Interactive' ) {
            // do something
            clearInterval(timer);
            return;
        }
    }, 500);

 

Guess you like

Origin www.cnblogs.com/warling/p/12076896.html