Ver Mensaje Individual
  #223 (permalink)  
Antiguo 19/07/2005, 15:01
Avatar de Saruman
Saruman
 
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 20 años, 10 meses
Puntos: 5
225. cuando se presione la tecla ESCAPE se cierre una ventana

P: ¿Cómo hago para que cuando se presione la tecla ESCAPE se cierre una ventana?

R: así:

Código:
 
function _CloseOnEsc() {
if (event.keyCode == 27) { window.close(); return; }
}
function InitESC() {
document.body.onkeypress = _CloseOnEsc;
}
Utilización:

Código HTML:
 <body onload="InitESC();"></body> 
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.

Última edición por KarlanKas; 06/09/2005 a las 01:48