call value inside a JS variable as a JS function name

Posted by user1640668 on Stack Overflow See other posts from Stack Overflow or by user1640668
Published on 2012-09-01T15:18:21Z Indexed on 2012/09/01 15:38 UTC
Read the original article Hit count: 244

Filed under:

Hello I have a function to perform actions but name of the function is inside a variable...

below code will get the URL's hashed part example: #JHON and remove # and store it inside URLHASH variable..example: JHON

  var urlhash = document.location.hash;
  urlhash = urlhash.replace(/^.*#/, '');

always there is a function name from that value inside variable and i want to call value inside that variable as a function name

  window.onload=function() {
    Value inside URLHASH variable should run as a name of a variable. example: jhon();
  };

Is it possible ? I tried some codes but it calls variable name as a function not value inside the variable..help me..

© Stack Overflow or respective owner

Related posts about JavaScript