this is the first thing that jumps out at me:
setTimeout(knightsTour(newX, newY, board, visitedFields), 10);
you are calling the method knightsTour immediately here, rather than after the timeout. setTimeout takes a function reference and a delay. you can fix your statement by wrapping the actual call in an anonymous method
// method to generate an function reference with properly scoped variables
var fnGenerator = function(newX, newY, board, visitedFields) {
var wrapperFn = function() {
knightsTour(newX, newY, board, visitedFields)
};
return wrapperFn;
}
// call the generator and return the wrapping function
var fnToCall = fnGenerator(newX, newY, board, visitedFields);
// Go from there
setTimeout(fnToCall, 10);
so we're generating a new function which wraps your actual call to knightsTour and provides the correct parameters. using a seperate function for this is necessary since you're trying to call all this in a loop if you didn't do this every call to knightsTour would use the same values for the parameters (see javascript closures).
after this your board will load and your sequence will start.
alertafter the firstwriteBoard, you can then click "OK", let the next alert pop up, click "Don't let this page show any more popups", and then click "OK" again. The algorithm will then run through for at least a little while.