【问题标题】:JS multiple PDF download in Chrome is limited to 10Chrome中JS多个PDF下载限制为10个
【发布时间】:2019-10-20 11:36:43
【问题描述】:

我有一个小脚本可以在一页上下载多个 pdf。第一部分设置“下载”属性,这是有效的。

第二部分遍历页面上的每个 pdf 并触发点击,因此它强制在 chrome 中下载。 这也可行,但它只下载 10 个而不是 30 个或更多 pdf。

这是js还是chrome的限制?如何允许下载 30 个或更多的 pdf?

$( document ).ready(function() {

  $('.order-history tbody tr').each(function(){
   var orderid = $(this).find('td:first-child a:first-child').text().trim();
   $(this).find('td:nth-child(5) a').each(function(index){
   $(this).attr('download',orderid+'-'+(index+1));
   console.log(orderid+'-'+(index+1));
   });
 }); 


  var links = document.getElementsByTagName('a');

for(var count=0; count<links.length; count++) {
    var url = links[count].getAttribute('href');
    if(url && url.endsWith('.pdf')) {
        links[count].dispatchEvent(new MouseEvent('click'));
    }
}

 }); 

【问题讨论】:

    标签: javascript jquery google-chrome pdf download


    【解决方案1】:

    同时请求(包括下载)有一个限制,由大多数浏览器单独设置,因为让网站免费下载无限量的文档将是一个安全问题。

    我怎么看,你只能通过在用户/客户端的浏览器中编辑允许的同时请求的数量来直接解决这个问题。 我没有尝试过,但此链接可能会帮助您到 change the number of simultaneous downloads in Chrome (Windows)。

    一种间接的解决方案可能是将要下载的文件打包到一个 ZIP 文件中。这样,您可以对 1 个请求发出 30 个请求。

    【讨论】:

      猜你喜欢
      • 2012-02-26
      • 2019-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-24
      • 2017-08-04
      • 1970-01-01
      相关资源
      最近更新 更多