Академический Документы
Профессиональный Документы
Культура Документы
Javascript
Pablo Lled Rovira
Control de eventos con Javascript
Contenidos
Introduccin
Eventos
Ejemplos
Conclusin
1
Control de eventos con Javascript
Introduccin
Comunicacin Web
Servidor <-> Cliente
- Protocolos HTTP,FTP
2
Control de eventos con Javascript
Introduccin
Que es un evento?
Seal que se genera cuando el
usuario interacta con el cliente
Ejemplos:
Hacer clic en un botn
Presionar tecla en una caja de texto
3
Control de eventos con Javascript
Introduccin
Ejemplos:
Al cerrar una pgina se muestra mensaje
Al pulsar botn se limpian casillas de texto
4
Control de eventos con Javascript
Introduccin
Cliente - Usuario
5
Control de eventos con Javascript
Eventos
Caractersticas
6
Control de eventos con Javascript
Eventos
Ejemplos:
- onClick, onLoad, onDblClick
7
Control de eventos con Javascript
Eventos
Handlers mas importantes
Tipo de manejador Etiquetas
8
Control de eventos con Javascript
Eventos
Handlers mas importantes
Tipo de manejador Etiquetas
9
Control de eventos con Javascript
Eventos
Handlers mas importantes
Tipo de manejador Etiquetas
Eventos
Codigo
Patrn
<Etiqueta manejador=codigo a ejecutar>
Ejemplo
<input type="button" value=" Pulsar boton
onClick="window.alert('Hola mundo!')";>
11
Control de eventos con Javascript
Eventos
Ejemplos
onClick
<html>
<head>
<title>Ejemplo onClick</title>
</head>
<body>
<center>
<input type="button" value=" Pulsar boton para saludo... "
onClick="window.alert('Hola mundo!')";>
</center>
</body>
</html>
12
Control de eventos con Javascript
Eventos
Ejemplos
onLoad
<html>
<head>
<title>Ejemplo onLoad</title>
</head>
<body onLoad="boton.value='hola!'">
<center>
<input type="button" name="boton" value="" onLoad = " value=
'hola mundo!' ">
</center>
</body>
</html>
13
Control de eventos con Javascript
Eventos
Ejemplos
onFocus
<html>
<head>
<title>Ejemplo onFocus</title>
</head>
<body>
<center>
<input type=text" value=" Al coger foco muestra mensaje... "
onFocus="window.alert('Hola mundo!')";>
</center>
</body>
</html>
14
Control de eventos con Javascript
Eventos
Ejemplos
onResize
<html>
<head>
<title>Ejemplo onLoad</title>
</head>
<body onResize="alert('Hola mundo');">
</body>
</html>
14
Control de eventos con Javascript
Eventos
Ejemplos
onBlur
<html>
<head>
<title>Ejemplo onLoad</title>
</head>
<body>
<center>
<input type="text" size=30 name="texto" value="Al perder
foco muestra mensaje" onBlur = " alert('Hola mundo!');">
</center>
</body>
</html>
16
Control de eventos con Javascript
Eventos
Ejemplos
onChange
<html>
<head>
<title>Ejemplo onLoad</title>
</head>
<body>
<center>
<input type="text" size=30 name="texto" value="Al
modificar texto mensaje" onChange = " alert('Hola mundo!');">
</center>
</body>
</html>
17
Control de eventos con Javascript
Eventos
Ejemplos
onKeyPress
<html>
<head>
<title>Ejemplo onLoad</title>
</head>
<body>
<center>
<input type="text" size=30 name="texto" value="Al pulsar
tecla mensaje" onKeyPress = " alert('Hola mundo!');">
</center>
</body>
</html>
18
Control de eventos con Javascript
Eventos
Ejemplos
onMove
<html>
<head>
<title>Ejemplo onLoad</title>
</head>
<body>
<center>
<input type="text" size=30 name="texto" value="Al mover
muestra mensaje" onMove = " alert('Hola mundo!');">
</center>
</body>
</html>
19
Control de eventos con Javascript
Eventos
Ejemplos
onSelect
<html>
<head>
<title>Ejemplo onLoad</title>
</head>
<body>
<center>
<input type="text" size=30 name="texto" value="Al
seleccionar texto muestra mensaje" onSelect = " alert('Hola
mundo!');">
</center>
</body>
</html>
20
Control de eventos con Javascript
Eventos
Ejemplos
onUnload
<html>
<head>
<script language="JavaScript">
function Salida() {
if (confirm('Ests seguro de que quieres abandonar este
script?'))
return true;
else {
return false;}
}
</script>
</head>
<body bgcolor="white" onUnload="Salida()"> </body>
</html>
21
Control de eventos con Javascript
Eventos
Ejemplos
onReset
<html>
<head>
<title>Ejemplo onLoad</title>
</head>
<body>
<center>
<input type="text" size=30 name="texto" value="Al borrar
muestra mensaje" onReset = " alert('Hola mundo!');">
<input type="reset" size=30 name="boton"
value=Borrar" onClick = "texto.value = '';" >
</center>
</body>
</html>
22
Control de eventos con Javascript
Eventos
Ejemplos
onMouseDown
<html>
<head>
<title>Ejemplo onLoad</title>
</head>
<body>
<center>
<input type="text" size=30 name="texto" value="Pulsar
boton raton aqui para mensaje" onMouseDown = " alert('Hola
mundo!');">
</center>
</body>
</html>
23
Control de eventos con Javascript
Conclusin
2
Control de eventos con Javascript
Preguntas ?
Control de eventos con Javascript
Bibliografa
http://manuales.dgsca.unam.mx/javascript/Eventos.html
http://www.ulpgc.es/otros/tutoriales/JavaScript/cap6.htm
http://www.elcodigo.com/tutoriales/javascript/javascript5.htm
http://www.territoriopc.com/javascript/10.htm