Hola buenos días, estoy trabajando en un script que me hace un slide de código, en el cual, cuando pones el cursor encima se detiene, y luego se vuelve a reanudar.
Me gustaría saber si se puede sacar una variable definida en una función al script global, y en el caso de que se pudiera, saber cómo hacerlo.
Dejo el código aquí para que os podais hacer una idea, gracias.
Código:
tm = 0;
tm2 = 143;
tm3 = 286;
tm4 = 429;
function timer1(){
document.getElementById('capa1').style.top = tm;
document.getElementById('capa2').style.top = tm2;
document.getElementById('capa3').style.top = tm3;
if(tm<=-143){
tm = 429;
}else if(tm2<=-143){
tm2 = 429;
}else if(tm3<=-143){
tm3 = 429;
}else if(tm4<=-143){
tm4 = 429;
}else{
tm--;
tm2--;
tm3--;
tm4--;
}
}
var repetir = setInterval("timer1()",60);
function seguir(){
var repetir = setInterval("timer1()",60);
}
function detener(){
clearInterval(repetir);
}