How to make an array with functions?

Beschrijving

Functienamen zijn op te nemen in een tabel en via de index van deze tabel uitvoerbaar.

Aanmaken tabel

var functie_array=new Array;
functie_array["Eerste functie"]="naam eerste functie";
functie_array["Tweede functie"]="naam tweede functie";

Aanroepen functie

window[functie_array["Eerste functie"]]();

Voorbeeld

var easyview_functions=new Array();
easyview_setup_functions();
function easyview_setup_functions(){
  easyview_functions['iframe']="easyview_iframe_type";
  easyview_functions['picasa']="easyview_picasa_type";
  easyview_functions['flash']="easyview_flash_type";
  easyview_functions['flv']="easyview_flash_video_type";
  easyview_functions['mmp3']="easyview_flash_multi_mp3_type";
  easyview_functions['mp3']="easyview_flash_mp3_type";
  easyview_functions['quicktime']="easyview_quicktime_type";
  easyview_functions['youtube']="easyview_youtube_type";
  easyview_functions['vimeo']="easyview_vimeo_type";
  easyview_functions['silverlight']="easyview_silverlight_type";
}
window[easyview_functions['picasa']]();

Externe Links

  • How to execute a javascript function when i have its name as a string?
  • How to Convert String into a Variable?