Jump to content

How can I call this function?


Shanester

Recommended Posts

Greetings, I would like to call a function, but the name of a function is stored in another functions argument list, like this:

function chromeFix(funcName) {  funcName();}

The name of the function I want to call is passed to chromeFix as an argument. However, "funcName()" generates an error saying "Function expected". How can I call a function like this? PHP allows variable functions. Javascript either doesn't allow it, or I'm not doing it properly. Thanks,Shane.

Link to comment
Share on other sites

Greetings, I would like to call a function, but the name of a function is stored in another functions argument list, like this:
function chromeFix(funcName) {  funcName();}

The name of the function I want to call is passed to chromeFix as an argument. However, "funcName()" generates an error saying "Function expected". How can I call a function like this? PHP allows variable functions. Javascript either doesn't allow it, or I'm not doing it properly. Thanks,Shane.

the name isn't "stored" in the arguments, that's just how the Chromefix function knows how to reference it. the error is pretty clear though. It says it is expecting a function, as dsonesuk is showing you in his example.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...