Variable javascript

bill -  
avion-f16 Messages postés 19182 Date d'inscription   Statut Contributeur Dernière intervention   -
Bonjour,
J'ai de l' ajax qui me retourne le nom d'une fonction et je voudrais une fois retournée l'exécuter comment faire ?
Configuration: Windows XP / Firefox 3.5.8

1 réponse

  1. avion-f16 Messages postés 19182 Date d'inscription   Statut Contributeur Dernière intervention   4 511
     
    Il y a la fonction eval() mais je doute que se soit la meilleure des solutions.
    Ou bien tu peux appeler une fonction et lui préciser le nom de la fonction comme ça :
    function executer(fonction) {
        if(fonction == 'nomdunefonction')
            nomdunefonction();
        if(fonction == 'uneautrefonction')
            uneautrefonction();
        // ...
    }
    0