SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Forensic SEO Consultant Webnauts's Avatar
    Join Date
    Jun 2003
    Location
    European Union
    Posts
    1,488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using BOTH onkeypress and onclick - redundant ?

    Someone have passed me this message:

    I have created two links and a JavaScript function. To ensure keyboard
    accessibility, I understand that I should use both onClick and onKeyPress.
    These would normally be used to open a popup window, not an alert box.

    <a href="popup.html" onclick="popup('popup.html')">onclick</a>
    <a href="popup.html" onkeypress="popup('popup.html')">onkeypress</a>

    function popup(url){
    window.open(url, ...);
    }

    In Opera, the onClick event handler is fired by pressing Enter (which
    doesn't make sense, I think). But the onKeyPress activates the link when I
    navigate off it by pressing the A key. The first behaviour suggests that
    onKeyPress is unnecessary. The second, that using onKeyPress actually makes
    the page unusable. Internet Explorer seems to ignore the tab key press when
    tabbing through the links.

    Am I missing something here? Can I tell people to use onKeyPress as a
    redundant even handler, knowing that it misbehaves in Opera?

    CAN ANYBODY HELP?

  2. #2
    Forensic SEO Consultant Webnauts's Avatar
    Join Date
    Jun 2003
    Location
    European Union
    Posts
    1,488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Webnauts
    Someone have passed me this message:

    "I have created two links and a JavaScript function. To ensure keyboard
    accessibility, I understand that I should use both onClick and onKeyPress.
    These would normally be used to open a popup window, not an alert box.

    <a href="popup.html" onclick="popup('popup.html')">onclick</a>
    <a href="popup.html" onkeypress="popup('popup.html')">onkeypress</a>

    function popup(url){
    window.open(url, ...);
    }

    In Opera, the onClick event handler is fired by pressing Enter (which
    doesn't make sense, I think). But the onKeyPress activates the link when I
    navigate off it by pressing the A key. The first behaviour suggests that
    onKeyPress is unnecessary. The second, that using onKeyPress actually makes
    the page unusable. Internet Explorer seems to ignore the tab key press when
    tabbing through the links.

    Am I missing something here? Can I tell people to use onKeyPress as a
    redundant even handler, knowing that it misbehaves in Opera?

    CAN ANYBODY HELP?
    Use "onclick" with "onkeypress"?

    The User-Agent accesibility guideline 1.2
    http://www.w3.org/TR/UAAG10/guideli...endent-handlers states:

    "Allow the user to activate, through keyboard input alone, all input device
    event handlers that are explicitly associated with the element designated by
    the content focus."

    I asumed that the implementation of onclick is interpreted to mean activated
    in any way, but is it specified anywhere? If it is then I understand that
    there's no need for redundant event handlers.

    WCAG techniques say: http://www.w3.org/TR/WCAG10-HTML-TE...essible-scripts

    Use "onclick" with "onkeypress".

    But this suggests that the technique is no longer necessary, because the browsers have overcome the problem.

    Opera doesn't use the tab key for link navigation. It uses A and Q instead."

    [img]images/smilies/yawnb.gif[/img] Any comments please?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •