I'm trying to download some PDF files from a server. there is no direct address for files, so I have to launch a url, then a temporary link will create and browser start to download it with a download manager.
I already used this code to open urls with delay
<!doctype html>
<html>
<head>
<title>Open Windows</title>
<script>
function openWindow(){
var x = document.getElementById('a').value.split('\n');
atTime = 0;
for (var i = 0; i < x.length; i++) {
if (x[i].indexOf('.') > 0) {
site = x[i];
if (x[i].indexOf('://') < 0) { site = 'http://' + x[i]; }
setTimeout("window.open('" + site + "')", atTime);
atTime += 20000;
}
}
}
</script>
<style>
html, body
{
height : 99%;
width : 99%;
}
textarea
{
height : 80%;
width : 90%;
}
</style>
</head>
<body>
<textarea id="a"></textarea>
<br>
<input type="button" value="Open Windows" onClick="openWindow()">
<input type="button" value="Clear" onClick="document.getElementById('a').value=''">
</body>
</html>
here is my question:
How can I customize this code to get some urls, open them in the browser (an starting a download), then check if the file downloaded (exist) in a path on my hard drive (D:\downloads), start the other line to open.
this is an example of url
http://www.example.com/download.php?token=87345&pid=12345
and this is the file name : 12345.pdf
Thanks in advance!