Send multiple files to the user for download one after another

前端 未结 2 1526
一整个雨季
一整个雨季 2021-01-28 19:42

I\'m trying to do the following:

  • A grid with a lot of files is shown to the user
  • The user selects as many files as he wants
  • The user should be pr
2条回答
  •  悲哀的现实
    2021-01-28 20:28

    I found a solution that works (for me) in all browsers. It's does not feel that good on the code side (at first) but it seems pretty stable to me on different browsers and different machines.

    Chrome will ask the user to allow the site to download multiple files. IE doesn't care at all.

    var onDownload = function(){
           var docs = module.getSelectedElements();        
    
           for(var i = 0; i < docs.length; i ++) {
               (function(){
                   var doc = docs[i];
                   window.setTimeout(function(){
                      $jq("#downloadIframe").attr("src", doc.url);
                   }, i * 500);
               })();
           }
    
    };
    

提交回复
热议问题