Trent wrote:
[color=blue]
> But how do I assign a function to the onKeyUp event in *javascript*
> that can access the event object?
>
> // get inputElement
> alert("Some java script code");
> inputElement.onkeyup = ????;
>
> I know how to assign generic functions. This works:
>
> inputElement.onkeyup = function() { alert("hello"); };
>
> But how in the world do I assign a function that captures the "event"
> object? I want something like:
>
> inputElement.onkeyup = function(event) { processEvent(event) };
>
> But that doesn't work right. Any ideas?[/color]
That last attempt should work with Mozilla/Netscape however the problem
is that IE has a global variable window.event that your event parameter
shadows so you need
inputElement.onkeyup = function (evt) {
if (!evt) {
evt = window.event;
}
// now use evt e.g.
alert(evt.keyCode);
};
--
Martin Honnen
http://JavaScript.FAQTs.com/