[Javascript] Re: Re: Is this right Javascript?
Peter-Paul Koch
gassinaumasis at hotmail.com
Wed Apr 9 14:45:28 CDT 2003
>Test file:
>
><html><head></head>
><body>
><form name="Test1">
><textarea onkeydown="alert('hello')"></textarea>
></form>
></body></html>
>
>This did NOT work in these browsers under WIndows XP
>
>Netscape 4.6
>Netscape 7.02
>Explorer 6.0
>Opera 7
>
><textarea onClick="alert('hello')"> worked.
><textarea onKeyPress="alert('hello')"> did not.
Very odd. Tested in NN4.7, Moz1.3, Op7 and IE6, also under WinXP, and it
worked perfectly for me.
>Since I am unfamiliar with this onkeydown event I suspect I have missed
>something vital.
>If PPK says it works I believe it, but I need to know "how?"
>
>onKeyDown seems to be the proper capitalisation, but it made no difference.
HTML attributes are case insensitive, so capitalization doesn't matter.
><script type="text/javascript" language="JavaScript1.2">
><!--
>
>// Tell the browser you want to intercept ALL key press events
>// on the page and then define a function to handle them.
>document.captureEvents(Event.KEYPRESS);
>document.onKeyPress = myKeyPressHandler;
This is JavaScript and thus case sensitive. Should be
document.onkeypress = myKeyPressHandler;
Also, the captureEvents will give an error message in all browsers except
for NN4.7 . I'm afraid this example is not very well tested.
>Cliff Wootton in JavaScript Programmers Reference marks onkeydown event for
>textarea with warning and a "-" in the DOM column of the browser
>compatibility table for the textarea
>Flanagan ("Rhino" 3rd ed) notes that onKeyDown is not yet part of DOM
>standard. This may have changed. (and on relflection I would be
>embarrassed if asked to explain what that means, esp in practice)
Nope, hasn't changed yet, but that doesn't prevent the event from being well
supported.
ppk
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
More information about the Javascript
mailing list