Hi Ugo, Ugo Cei wrote:
Try this:function checkLogin(funarg) { if (user == null) login(); funarg(); }
This doesn't seem to work. It always generates an error message like "org.mozilla.javascript.EvaluatorException: checkout is not a function."
But if I invoke the same function directly from the sitemap, without passing its name as an argument, it works.
What's happening here?
Ugo
function checkLogin(funarg) {
if (user == null) {
login();
this[funarg]();
}
}
funarg is just the string "checkout", to get to the checkout() function you need to dereference the global scope object (this). In JavaScript, using the [] operator with a string argument behaves the same as using the dot operator. However, the dot operator requires a literal identifier. If you want to use a variable (as in this case) then you must use the [] operator.
Regards,
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]