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..
You can access attributes of objects as if they are array indexes, so for example, you could run
getElementByIdthis way:so& if you know beforehand of which object the function will be a member, you can access it this way. functions in the global scope are methods of the window object. However, if the hash may contain expressions like
#document.write(), you would have to do some parsing. it could work like this