El problema. que cuando cambio de un boton a otro los colores se aturullan, a que se debe?? una ayuda por favor!!
Grasias
Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <script language="JavaScript"> var t,inc=0x000101,color=0xFF0000,color1=0x00FF00,color2=0x0000FF; function cambiarcolor() { color+=inc; document.getElementById("p1").style.color=color; if (color==0xFFFFFF || color==0xFF0000) { inc*=-1; } } function azul() { color1+=inc; document.getElementById("p1").style.color=color1; if (color1==0xFFFFFF || color1==0x00FF00) { inc*=-1; } } function verde() { color2+=inc; document.getElementById("p1").style.color=color2; if (color2==0xFFFFFF || color2==0x0000FF) { inc*=-1; } } function fondo() { tiempo=0; for(i=0;i<5;i++) { tiempo += 1000; setTimeout("document.bgColor='#0000FF';",tiempo); tiempo += 1000; setTimeout("document.bgColor='#FFFFFF';",tiempo); tiempo +=1000; setTimeout("document.bgColor='#FF0000';",tiempo); tiempo +=1000; setTimeout("document.bgColor='#FFFFFF';",tiempo); tiempo +=1000; setTimeout("document.bgColor='#00FF00';",tiempo); tiempo +=1000; setTimeout("document.bgColor='#FFFFFF';",tiempo); tiempo +=1000; } } </script> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="body.css" rel="stylesheet" type="text/css"> </head> <body > <center> <h1 id="p1">Ya se hacer tonterias <br> en Javascript</h1><br><br> Código: <input name="codigo"> <br><br> <input type="button" value=" Cambiar a Rojo" onClick="t=setInterval('cambiarcolor()',1)" > <input type="button" value=" Cambiar a Azul" onClick="t=setInterval('azul()',1)"> <input type="button" value=" Cambiar a Verde" onClick="t=setInterval('verde()',1)"><br><br> <input type="button" value=" Cambiar Fondo" onClick="fondo()"> </form> </center> </body> </html>