Netscape 7.1 - why is event.preventDefault undefined

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    Netscape 7.1 - why is event.preventDefault undefined

    I have a textbox where I'm trying to restrict which keys a user can
    hit.
    My syntax is onKeyDown="myFu nction(event)"
    To restrict the keys, Netscape requires the event.preventDe fault
    method. Problem is, I'm getting and "undefined" for that method. The
    event object is ok as I'm able to get event.keyCode fine, but nothing
    for preventDefault.

    I've even tried something as simple as
    onKeyDown="aler t(event.prevent Default())", but still get undefined.
    Any ideas why?

    Thanks,
    Mike
  • Martin Honnen

    #2
    Re: Netscape 7.1 - why is event.preventDe fault undefined



    Mike wrote:
    [color=blue]
    > I have a textbox where I'm trying to restrict which keys a user can
    > hit.
    > My syntax is onKeyDown="myFu nction(event)"
    > To restrict the keys, Netscape requires the event.preventDe fault
    > method. Problem is, I'm getting and "undefined" for that method. The
    > event object is ok as I'm able to get event.keyCode fine, but nothing
    > for preventDefault.
    >
    > I've even tried something as simple as
    > onKeyDown="aler t(event.prevent Default())", but still get undefined.
    > Any ideas why?[/color]

    Well,
    alert(event.pre ventDefault())
    calls the method and then alerts its result and as the method is not
    supposed to return anything the result of the call is the value
    undefined and the alert shows just that.

    As for cancelling keys with Netscape 7 or Mozilla you can only do that
    in the keypress event handler, it doesn't work for the keydown event
    handler so I am sure
    <input onkeypress="if (event.keyCode == 'A'.charCodeAt( )) {
    if (event.preventD efault) {
    event.preventDe fault();
    }
    return false;
    }
    else {
    return true;
    }"
    will do.


    --

    Martin Honnen


    Comment

    • DU

      #3
      Re: Netscape 7.1 - why is event.preventDe fault undefined

      Mike wrote:
      [color=blue]
      > I have a textbox where I'm trying to restrict which keys a user can
      > hit.
      > My syntax is onKeyDown="myFu nction(event)"
      > To restrict the keys, Netscape requires the event.preventDe fault
      > method. Problem is, I'm getting and "undefined" for that method. The
      > event object is ok as I'm able to get event.keyCode fine, but nothing
      > for preventDefault.
      >
      > I've even tried something as simple as
      > onKeyDown="aler t(event.prevent Default())", but still get undefined.
      > Any ideas why?
      >
      > Thanks,
      > Mike[/color]

      The preventDefault( ) method works accordingly in NS 7.1. Maybe we could
      figure out your problem if we could examine your page; what's the url?

      DU

      Comment

      Working...