Attach event handler to window events?

Last post 11-13-2006 11:01 AM by mhil_cbtech. 0 replies.

Sort Posts:

  • Attach event handler to window events?

    11-13-2006, 11:01 AM

    I'm trying to set up some script to respond to onkeypress events on the window object. I want to respond to the window event instead of a textbox event because I'm trying to enable Excel-like nagivation between for elements using the arrow keys. The following works in Firefox, but not IE:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Page</title>
    <script type="text/javascript" src="MicrosoftAjax.js"></script>
    <script type="text/javascript">
      <!--
      function testkeypress()
      {
        alert("keypress event detected!");
      }
      $addHandler(window, 'keypress', testkeypress);
      //-->
      </script>
    </head>
    <body>
      <p>Untitled Page</p>
    </body>
    </html>
    

     Can anyone point out what I'm doing wrong or provide an example of how to do this? Thanks in advance.

     -Mark

Page 1 of 1 (1 items)
Microsoft Communities
Page view counter