When I try to run this program, I get an error in Firefox saying that:
moveDate is undefined on line 41
(referring to the line window.setTimeout("moveDate()",100);.
Any ideas why? I thought recursive functions were able to define themselves and then call upon themselves.
function monthScroller(){
document.getElementById("month").style.visibility = "visible";
var x = 0;
var y = 0;
var dest_x = window.innerWidth/2;
var dest_y = window.innerHeight/2;
var interval = 1;
function moveDate() {
if(x<dest_x){ x = x + interval;}
if(y<dest_y){ y = y + interval;}
document.getElementById("month").style.top = y+"px";
document.getElementById("month").style.left = x+"px";
if ((x+interval < dest_x) && (y+interval < dest_y)) {
window.setTimeout("moveDate()",100);
}
else{
name();
}
}
moveDate();
}
eval()isevil. Don't use those, including that one insetTimeout("").setTimeoutandsetInterval(and Function), they were side issues. The only problem with its use here relates to efficiency (ignoring the scope issue), none of the other "evilness" of eval is relevant here.