SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2003
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    NS6 Keypress Problem

    I am working on a routine that will cancel the keypress event. I have this working except for when I wire the events up using listeners. I have a simplified example and I don't understand why I can't cancel the event when I use the listener approach.

    Any help would be great...
    Thanks!

    ======== CODE ========
    <html><body>
    With Event Listener: <INPUT type="text" ID="txtNs" NAME="txtNs">
    Without event listener: <INPUT type="text" ID="Text1" onkeypress="NSCheck(event);" NAME="txtNs">
    <SCRIPT>
    var ns = document.getElementById('txtNs');
    ns.addEventListener("keypress",NSCheck,true);

    function NSCheck(e)
    {
    // THIS SHOULD CANCEL THE EVENT!!!
    e.preventDefault();
    }
    </SCRIPT>
    </body></html>

  2. #2
    SitePoint Zealot tss68nl's Avatar
    Join Date
    Nov 2002
    Location
    Netherlands
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well it isnt the Mozilla component the browser is based on thats faulty, because on Firebird (A lightweight mozilla based browser) it works fine. Needles to say the both browsers use the same core.

    Unfortunatly I refuse to install netscape on this machine, so I cant test the code on that.


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
  •