Hi.
Ich habe mir multiDownload heruntergeladen und folgendes Script funktioniert zu meiner Zufriedenheit:
Diese Funktionalität möchte ich in einem GreaseMonkeys Script nutzen. Das Script läuft auf einer Seite die bereits jQuery enthält, deshalb habe ich nicht erneut ein jQuery Library in folgenden Script geladen:
Den Fehler den ich erhalte:
Ich habe mir multiDownload heruntergeladen und folgendes Script funktioniert zu meiner Zufriedenheit:
PHP:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.multiDownload.js"></script>
<title>jQuery multiDownload Plugin Demo</title>
</head>
<body>
<ul>
<li><a href="1.zip" class="my-file">File 1</a></li>
<li><a href="2.zip" class="my-file">File 2</a></li>
<li><a href="3.zip" class="my-file">File 3</a></li>
</ul>
<a href="#" id="download-all">Download All</a>
<script>
$('#download-all').click(function (event) {
event.preventDefault();
$('.my-file').multiDownload();
});
</script>
</body>
</html>
Diese Funktionalität möchte ich in einem GreaseMonkeys Script nutzen. Das Script läuft auf einer Seite die bereits jQuery enthält, deshalb habe ich nicht erneut ein jQuery Library in folgenden Script geladen:
PHP:
var imported = document.createElement('script');
imported.src = 'jquery.multiDownload.js';
imported.type = 'text/javascript';
document.head.appendChild(imported);
$(document).ready(function(){
url="1.zip";
var anker = document.createElement('a');
anker.href = url;
anker.class = "my-file";
var downloadAnker = document.createElement('a');
downloadAnker.href = "#";
downloadAnker.id = "download-all";
downloadAnker.innerHTML = "Download";
$('#mitte').append(anker);
$('#mitte').append(downloadAnker);
$('#download-all').click(function (event) {
event.preventDefault();
$('.my-file').multiDownload();
});
});
Den Fehler den ich erhalte:
Code:
TypeError: $(...).multiDownload is not a function