On Tue, 12 Oct 2004 21:08:59 +0200, oeyvind toft <oeyvtoft@onlin e.no>
wrote:
[color=blue]
> myObj.onmouseov er = someFunction;
>
> How can I set up this so myObj can send parameters to the function ?[/color]
An element doesn't "send" anything to its event listeners. The browser
calls listeners directly, using the element to obtain a reference for use
with the this operator.
As for calling a function with arguments, you'll have to introduce an
intermediate function which is called as the listener. It can then call
someFunction, in turn. For example,
myObj.onmouseov er = function(e) {
someFunction(
this, // reference to myObj
e || event // event object
);
};
creates an anonymous function which is added as the mouseover listener for
myObj. When called, the this operator will refer to myObj, and on
DOM-compliant browsers, e will be the event object.
Hope that helps,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Comment