locked
How to close web form by hitting Esc Button RRS feed

  • Question

  • I tried with window's concepts but its not working,
    can anybody suggest me an idea to close the web form by Esc key.
    Saturday, April 4, 2009 10:12 AM

Answers

  • This is the method to close the window by hitting Esc button:

    <

    script language="JavaScript">

    <!--

     

    // set up page to capture keypress events.

     

    if (document.layers)

    document.captureEvents(Event.KEYPRESS);

     

    function backhome(e){

     

    if (event.keyCode=='27'){window.close();}

    }

     

    // point keypress events to our function

    document.onkeypress=backhome;

     

    //-->

     

    </script>

    Saturday, April 4, 2009 10:32 AM