Debes tener en cuenta el alcance de las variables, no es lo mismo asignar un valor a url en la función showUser (precedida de var) que hacerlo en la función horas (precidada o no de var)
Con este ejemplo creo que quedará claro:
Código Javascript
:
Ver originalfunction funcion1() {
var url = 'http://test/';
funcion2();
alert(url);
}
function funcion2() {
url = 'http://other/';
}
function funcion3() {
var url = 'http://test/';
url = 'http://other/';
alert(url);
}
function funcion4() {
url = 'http://test/';
funcion2();
alert(url);
}
funcion1(); /* http://test/ */
funcion3(); /* http://other/ */
funcion4(); /* http://other/ */
Debes tener en cuenta que no siempre es lo mismo usar var o no al asignar el valor de una variable.