function theFunction(a){
var newNum = a+1;
var iframe = document.createElement("iframe");
var currURL = urlArray[a];
iframe.src = currURL;
iframe.frameBorder = "0";
iframe.height = "0";
iframe.width = "0";
iframe.onload = function(){
document.getElementById('number').innerHTML = a;
};
var arrayLength = someArray.length;
if(a != arrayLength){
theFunction(newNum);
}
}
This is my basic function that is recursive through an array. Anyways, sometimes as it goes through (during the //do nothing part). It will get stuck, and I want it to timeout after say 2 seconds AND move onto the next one. Is this possible to do, or will I just have to completely stop the function?
EDIT: Set timeout might not be what I am looking for, but some way to just stop the function and move to the next one.
EDIT 2: Added more to the code