PDA

View Full Version : How to Close Pop up by pressing ESC Key



jee14u
01-18-2008, 12:01 PM
Hi,

Please tell me.

in my application i opened some popups.
to close that popups wrote script window.top.close to close button.
ok it is working

but i want to Close Pop up when i pressing ESC Key.

no mouse actions only keybord esc key.

how can i do it. please tell me anybody knows.

Thanks,

???
01-18-2008, 03:43 PM
Put this in the popup. It should work.

<script type="text/javascript">
window.onkeyup = function (event) {
if (event.keyCode == 27) {
window.close ();
}
}
</script>

SAJI NAIR
01-30-2008, 03:04 PM
can you pl. tell me where to put this script? in <head> or <body>

jscheuer1
01-31-2008, 05:45 AM
You shouldn't co-opt the Esc key to do anything. It already has functions in several browsers.