Detect when browser receives file download

前端 未结 22 1781
陌清茗
陌清茗 2020-11-21 04:55

I have a page that allows the user to download a dynamically-generated file. It takes a long time to generate, so I\'d like to show a \"waiting\" indicator. The problem is,

22条回答
  •  故里飘歌
    2020-11-21 05:45

    Create an iframe when button/link is clicked and append this to body.

                      $('');
                                    frame.attr('src', url+"?"+ "Content-Disposition: attachment ; filename="+that.model.get('fileName'));
                                    $(ev.target).after(frame);
                                    setTimeout(function() {
                                        frame.remove();
                                    }, cleaningDelay);
                                }, triggerDelay);
    

提交回复
热议问题