[Javascript] Re: Re: Is this right Javascript?

Rodney Myers rodney at aflyingstart.net
Wed Apr 9 13:28:44 CDT 2003


Thanks for the reply, and sorry for your trouble.

I feel a complete fool!
I was testing with mouseclicks
The event worked with a keypress of a letter. (even ion NN4.6)

However the Pure Javascript example still did NOT work and gave the same 
error.

Rodney


Chris Tifer wrote:

>Hmmmm. I'm on Win 2000 and it works in all but the NN 4.6 (which
>I don't have to test, but as I suggested earlier, I didn't expect it to work
>with that version).
>
>I'll have to take a look at it on my XP machine at home. If it works
>for me on that machine, it might depend more on which versions of
>JScript we have installed. Just because we have the same browser
>versions does not mean we have the same script builds, right?
>
>Chris Tifer
>http://www.emailajoke.com
>
>
>
>----- Original Message -----
>From: "Rodney Myers" <rodney at aflyingstart.net>
>To: "[JavaScript List]" <javascript at LaTech.edu>
>Sent: Wednesday, April 09, 2003 1:21 PM
>Subject: Re: [Javascript] Re: Re: Is this right Javascript?
>
>
>  
>
>>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.
>>
>>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.
>  
>
>>Furthermore, this file taken verbatim from "Pure Javascript" by Wyke et
>>al (2nd Ed) did not work either.
>>in Explorer it gave the error 'Event' is undefined.
>>
>>(It is a good book, but the examples on the CD were poorly proofread imho)
>>
>><html>
>><head>
>>
>><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;
>>
>>// Define the myKeyPressHandler function to handle
>>// key press events.
>>function myKeyPressHandler(e){
>>  alert("A key press event took place within the document!");
>>}
>>
>>// -->
>></script>
>></head>
>><body>
>>Anytime you press a key within this document, you will
>>get a message alerting you that a KeyPress event has taken place.
>></body>
>>
>>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)
>>
>>Puzzled.....
>>
>>Rodney
>>
>>Peter-Paul Koch wrote:
>>
>>    
>>
>>>      
>>>
>>>>>  Third, 'onkeydown' is undefined for normal JavaScript (although
>>>>>          
>>>>>
>>>>it may  have
>>>>        
>>>>
>>>>>  some bizarre other-worldly existence in M$oft's bastardized
>>>>>          
>>>>>
>>>>JScript).
>>>>        
>>>>
>>>>>  I suspect the event you were attempting to intercept was
>>>>>          
>>>>>
>>>>'onclick',  which
>>>>        
>>>>
>>>>>  IS defined, and actually makes sense for a checkbox.
>>>>>          
>>>>>
>>>>I know it's cool to bash Microsoft whenever the chance arises, but a
>>>>simple sample would show you this is not some "bastardized"
>>>>javascript unless NN is now bastardizing it too:
>>>>
>>>><form name="Test1">
>>>>
>>>>
>>>><textarea onkeydown="alert('hello')"></textarea>
>>>>
>>>></form>
>>>>
>>>>
>>>>Put that on a page and view it in NN and you'll see it works fine, as
>>>>long as you're not using the ultimate in bastardized browsers - NN4.7
>>>>        
>>>>
>>>It even works in NN4.7 The Key events have been around, and well
>>>supported, since the Version 4 browsers.
>>>      
>>>
>>
>>
>>_______________________________________________
>>Javascript mailing list
>>Javascript at LaTech.edu
>>https://lists.LaTech.edu/mailman/listinfo/javascript
>>    
>>
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>  
>

-- 
PS. I have just bought a licence for Mike Chen's
BizAutomator. If you have to answer routine 
email queries from your sites or mailings then
you need this as much as I do. 
http://www.BizAutomator.com/rlbm51 

Rodney






More information about the Javascript mailing list