X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fclose_on_esc.js;h=a60e9a651c21a2c107438019ddef256ea330b676;hb=9deb52b6e324bb69442bc33d537dbcb7d77949a6;hp=f4f3d878bf8e424ede15180b41db30c73787ce88;hpb=0337d704b62718d7c77106c0e4c4e26fb02beacf;p=platal.git diff --git a/htdocs/javascript/close_on_esc.js b/htdocs/javascript/close_on_esc.js index f4f3d87..a60e9a6 100644 --- a/htdocs/javascript/close_on_esc.js +++ b/htdocs/javascript/close_on_esc.js @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2003-2004 Polytechnique.org * + * Copyright (C) 2003-2006 Polytechnique.org * * http://opensource.polytechnique.org/ * * * * This program is free software; you can redistribute it and/or modify * @@ -18,14 +18,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -function closePopup() { - window.close(); -} -if (navigator.appName=="Microsoft Internet Explorer") { - function keyboardIE() { if (event.keyCode == 27) closePopup(); }; - document.onkeydown = keyboardIE; -} else { - function keyboardOther(e) { if (e.keyCode == 27) closePopup(); }; - document.onkeydown = keyboardOther; +function closePopup(e) { + e = e || window.event; + if (e.keyCode == 27) { + window.close(); + } } +attachEvent(window, 'keydown', closePopup); +