facebook auto post php script | when mysql support will be replaced with mysqli | pdo dynamically bind
 


 

Call javascript Function Using Variable for its Name



What is the javascript equivalent of PHP call-user-func?

To call a user-defined javascript function, for example DoReload(), you have just to write its name:

DoReload();

In case you want to call this function using a variable holding its name, for example

var function_to_call = 'DoReload';

just write:

window[function_to_call]();

Hope to find it helpful. Your comments are welcomed!

Εγγραφή!
Sign-up for our free email newsletter. Get updates when new tutorials and tips are published. You can unsubscribe anytime with a click.

Your comments are welcomed!

This site actively encourages commenting on any post. Comments are not pre-moderated, but this community does not tolerate direct or indirect attacks, name-calling or insults. Please, read terms of use and Comment Policy at privacy policy.

More tips