I am trying to load some hundreds of urls from a local text file.
I was able to load them into an array.
I want to load them sequentially after certain time interval.
The script works fine if I remove setinterval but without it only 1 url gets loaded. Is there any other way to load all urls automatically 1-by-1.

Here is the code:

<html>
<head> </head>
<script type="text/javascript">
var allText =[];
var allTextLines = [];
var Lines = [];
var txtFile = new XMLHttpRequest();
//var i=0;
txtFile.open("GET", "URL.txt", true);
allText = txtFile.responseText;

txtFile.onreadystatechange = function f()
{
if (txtFile.readyState == 4)
{
allText = txtFile.responseText;
allTextLines = allText.split(/\r\n|\n/);//the urls are separated by /n
document.write(allText);
var i=Math.floor(Math.random()*100);
window.location=allTextLines[i];
setInterval(f(),5000);// trying to load after 5 sec.
}
else {
//alert("Didn't work");
}
}
txtFile.send(null);
// <body onLoad="setInterval('f()', 30000)">

/* function onLoad(URL){
if(onLoad.loaded)
window.setTimeout(f,0);
else if (window.addEventListener)
window.addEventListener("load",f,false);
else if (window.attachEvent)
window.attachEvent("onload",f);
}
onLoad.loaded=false;
onLoad(function() { onLoad.loaded=true; }); */

</script>

</html>