Thank you for helping,
alex
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html">
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<TITLE></TITLE>
<script LANGUAGE=javascript>
function Translate(e)
{
var key; // key pressed
if(!e)
var e = window.event;
key = e.keyCode;
if(key >= 97 && key <= 122) // lowercase letters
{
e.keyCode = key - 32; // uppercase
}
}
</script>
</HEAD>
<BODY>
<center>
<br>
<form method=post id=idfNotepad>
<TEXTAREA onkeypress=Translate() id=idfTextarea rows=18
cols=70></TEXTAREA>
</form>
</center>
</BODY>
</HTML>
Gecko DOM Event Reference
http://www.mozilla.org/docs/dom/domref/dom_event_ref.html
Document Object Model (DOM) Level 2 Events Specification
http://www.w3.org/TR/DOM-Level-2-Events/
--
Steve
It often shows an excellent command of language to say nothing. -Karol Newlin
Thank you very much for offering your help. I did look
into specs even before posting this message.
Unfortunately, I was not able to figure out the solution.
http://www.w3.org/TR/DOM-Level-2-Events/ tells me
that "The DOM Level 2 Event specification does not provide
a key event module."
http://www.mozilla.org/docs/dom/domref/dom_event_ref.html
lists keyCode as a valid property, although "Not part of
specification", but Mozilla does not recognize it.
Since you already took time to help me, could you please
be more specific, how to solve my problem.
Thanks again,
alex
>.
>
check the docs:
http://www.mozilla.org/docs/dom/domref/dom_event_ref6.html#1003390
etan
Thank you very much for offering your help. I did
try .charCode property. It appears to be read only
property, the same as .which property.
When I try to assign a new key value, Mozilla's JavaScript
console reports an error: setting a property that has only
a getter.
Thanks again,
alex
>.
>
If Mozilla won't let you change the key code inside the handler, I guess you
have to take over the whole event.
function Translate(e) {
var key = e.charCode;
if (key >= 32) {
e.preventDefault();
if (key >= 97 && key <= 122) key -= 32;
e.target.value = e.target.value + String.fromCharCode(key);
}
}
[ Cross-browser version left as an exercise. ;-) ]
--
Steve
Nearly all men can stand adversity, but if you want to test a man's character,
give him power. -Abraham Lincoln
e.target.value = e.target.value + String.fromCharCode(key);
is not what I need. It will append to what is accumulated
in TEXTAREA instead of inserting the char at cursor
position.
What I need is to get an event, find what key was pressed
and redefine the event as if a different key was pressed.
Something similar to what is easily done in IE:
e.keyCode = newkey;
Uppercasing TEXTAREA input was just a simple convenient
example to illustrate the problem, but my goal was not to
manipulate the contents of TEXTAREA directly, because the
target may not be the TEXTAREA.
Thank you again,
alex
>.
>
Alex, did you find the solution? I've just met the same problem
and found your post via Google Groups searching for the error
"setting a property that has only a getter"
--
Regards,
Paul Gorodyansky
"Cyrillic (Russian): instructions for Windows and Internet":
http://ourworld.compuserve.com/homepages/PaulGor/