Ich habe eine Webseite, wo ich eine zufällige Anzahl von Dateien zum Download finden kann. Ich wollte eine kleine FireFox-Erweiterung entwickeln, um alle Dateien gleichzeitig herunterzuladen. Bisher habe ich die folgende Funktion, diese Dateien zum Download:Trigger mehrere Links zum Download von Dateien
function getFilesJQ() {
var $dlLinks = $('a').filter(function(index) { return $(this).text() === "Download"; });
$dlLinks.each(function() {
$(this).trigger('click');
});
}
Das Problem ist, dass nur der erste Link geklickt wird und die entsprechende Datei beginnt zum Download bereit. Die anderen werden nicht ausgelöst.
Wo liegt das Problem? Ist das überhaupt möglich?
Edit:
Dies ist, wie $ dlLinks wie folgt aussieht:
{…}
0: <a id="exerciseResourcesForm:a3:0:linkDownload" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('exerciseResourcesForm'),{'exerciseResourcesForm:a3:0:linkDownload':'exerciseResourcesForm:a3:0:linkDownload'},'');}return false">
1: <a id="exerciseResourcesForm:a3:1:linkDownload" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('exerciseResourcesForm'),{'exerciseResourcesForm:a3:1:linkDownload':'exerciseResourcesForm:a3:1:linkDownload'},'');}return false">
2: <a id="exerciseResourcesForm:a3:2:linkDownload" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('exerciseResourcesForm'),{'exerciseResourcesForm:a3:2:linkDownload':'exerciseResourcesForm:a3:2:linkDownload'},'');}return false">
3: <a id="exerciseResourcesForm:a3:3:linkDownload" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('exerciseResourcesForm'),{'exerciseResourcesForm:a3:3:linkDownload':'exerciseResourcesForm:a3:3:linkDownload'},'');}return false">
length: 4
prevObject: Object { 0: a, 1: a, 2: a, … }
__proto__: Object { jquery: "3.2.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector", constructor: r(), length: 0, … }
jack_download.js:10:2
Wenn einer dieser Links geklickt wird, Anfragen POST ausgegeben:
POST
https://*******/emp/ExerciseEdit.jsf
[HTTP/1.1 200 OK 28ms]
POST
https://sb-ssl.google.com/safebrowsing/clientreport/download
[HTTP/2.0 200 OK 109ms]
Bitte zeigen Sie, wie '$ dlLinks' aussieht wie – brk
@brk Fertig. ..... –