jueves, 1 de mayo de 2008

Codigo JAVASCRIPT + HTML

Ejemplo: Este ejemplo lo puedes copiar en un blog de notas y guardarlo con
extension html y veras la funcion de java script

< html >< head >
< script languaje="Javascript" > function calcula(form) {
if (confirm("¿Está seguro?"))
form.resultado.value = eval(form.expr.value)
else alert("Vuelva a intentarlo...") }

< body bg style="color:#99CC99;" >< form >< span style="Tahoma" > Introduzca una expresión:
< input type="text" name="expr" size="15" >
< input type="button" name="Boton" value="Calcular" onclick="calcula(this.form)" > < br /> Resultado:< /b > < input type="text" name="resultado" size="15" >
< br />< /form >
< script language="JavaScript" >
function mueveReloj(){ momentoActual = new Date() hora = momentoActual.getHours() minuto = momentoActual.getMinutes() segundo = momentoActual.getSeconds()
str_segundo = new String (segundo) if (str_segundo.length == 1) segundo = "0" + segundo
str_minuto = new String (minuto) if (str_minuto.length == 1) minuto = "0" + minuto
str_hora = new String (hora) if (str_hora.length == 1) hora = "0" + hora
horaImprimible = hora + " : " + minuto + " : " + segundo
document.form_reloj.reloj.value = horaImprimible
setTimeout("mueveReloj()",1000) } < /script > < /head >
< body onload="mueveReloj()" >

< form name="form_reloj" > < input type="text" name="reloj" size="10" style="background-color : #33CCFF; color : black; font-family : Verdana, Arial, Helvetica; font-size : 8pt; text-align : center;" onfocus="window.document.form_reloj.reloj.blur()" > < /form >
< /body >< /html >

No hay comentarios: