Jump to content

How can I call this function?


Shanester
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...