Just trying to create some moving layers, and came across this code in a book:
I find it counter-intuitive somehow to have the function call itself within the function [setTimeout("showlayer()"] - I feel as if the function doesn't yet exist at this point, so how can it be called? Am I wrong? Should I have some coffee?!
Code:
function showlayer() {
var hiddenlayer = document.getElementById('tablayer');
var layerposition = parseInt(hidden.style.left);
if (layerposition < 0) {
hiddenlayer.style.left = (layerposition + 5) + "px";
setTimeout("showlayer()", 20);
}
}
I find it counter-intuitive somehow to have the function call itself within the function [setTimeout("showlayer()"] - I feel as if the function doesn't yet exist at this point, so how can it be called? Am I wrong? Should I have some coffee?!