Don't like ads? PRO users don't see any ads ;-)

Eventos en Javascript

By: Jesse315 on Jun 14th, 2012  |  syntax: JavaScript  |  size: 0.70 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE HTML>
  2. <html lang="es-VE">
  3.         <head>
  4.                 <title> Javascript </title>
  5.                 <meta charset="UTF-8"/>
  6.         </head>
  7.         <body>
  8.                 <button id="miButton">Click Aqui!</button>
  9.                 <script type="text/javascript">
  10.                         window.addEventListener("load",function(){
  11.                                 alert("La pagina ha cargado satisfactoriamente");
  12.                         });
  13.                         var boton = document.getElementById("miButton");
  14.                         window.addEventListener("keydown",tecla_pulsada);
  15.                         boton.addEventListener("click",boton_pulsado);
  16.                         function boton_pulsado(evento){
  17.                                 alert("Has pulsado el boton");
  18.                                 boton.removeEventListener("click");
  19.                                 alert(evento.type);
  20.                         }
  21.                         function tecla_pulsada(event){
  22.                                 alert(event.keyCode);
  23.                         }
  24.                 </script>
  25.         </body>
  26. </html>