Iframe.readyState does not work in chrome

后端 未结 4 882
长情又很酷
长情又很酷 2020-11-30 08:17

I create an Iframe on the fly and set as the url a page that downloads a binary file (xls, doc...). While files are downloading I show an animation. When do

4条回答
  •  被撕碎了的回忆
    2020-11-30 08:57

    Sarkiroka's solution worked for me. I have added an instance id to the cookie name to provide a thread safe solution:

    const instanceId = "some uuid retrieved from client";
    
    response.cookie(`fileDownloaded-${instanceId}`,'true', { path: '/', secure: true, maxAge: 90000});
    response.header('attachment','your-file-name.any');
    //...write bytes to response...
    

    client

    var checker = setInterval(()=>{
        if(document.cookie.indexOf(`fileDownloaded-${instanceId}`)>-1){
            alert('done');
            clearInterval(checker);
        }
    },100);
    
    

提交回复
热议问题