Netscape 7.1 - why is event.preventDefault undefined

M

Mike

I have a textbox where I'm trying to restrict which keys a user can
hit.
My syntax is onKeyDown="myFunction(event)"
To restrict the keys, Netscape requires the event.preventDefault
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="alert(event.preventDefault())", but still get undefined.
Any ideas why?

Thanks,
Mike
 
M

Martin Honnen

Mike said:
I have a textbox where I'm trying to restrict which keys a user can
hit.
My syntax is onKeyDown="myFunction(event)"
To restrict the keys, Netscape requires the event.preventDefault
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="alert(event.preventDefault())", but still get undefined.
Any ideas why?

Well,
alert(event.preventDefault())
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.preventDefault) {
event.preventDefault();
}
return false;
}
else {
return true;
}"
will do.
 
D

DU

Mike said:
I have a textbox where I'm trying to restrict which keys a user can
hit.
My syntax is onKeyDown="myFunction(event)"
To restrict the keys, Netscape requires the event.preventDefault
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="alert(event.preventDefault())", but still get undefined.
Any ideas why?

Thanks,
Mike

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top