[thelist] JS: assigning a function to an object question
Kelly Hallman
khallman at wrack.org
Fri Aug 29 23:11:32 CDT 2003
On Fri, 29 Aug 2003, Tom Dell'Aringa wrote:
> Speaking of unusual questions... I'm assigning a function to an object:
>
> img.onclick = functionA;
> function functionA() { blah }
>
> Problem: I need to send 2 parameters to this function.
Use a lambda function, which is called a function literal in Javascript:
img.onclick = function() { functionA(p1,p2); };
Function literals are in Javascript 1.2. If you only have 1.1, you can use
a Function() constructor. Anything older, you may be outta luck.
--
Kelly Hallman
http://wrack.org/
More information about the thelist
mailing list