call a function based on what the hash is

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Lindsay

    #1

    call a function based on what the hash is

    I've got the following code:

    Code:
    var hash = location.hash;
    		
    setInterval(function()
    {
        if (location.hash != hash)
        {
            hash = location.hash;
    	callFn = location.hash.substring(1);
    	callFn();
        }
    }, 100);
    I want to call a function based on what the hash is. Clearly I'm doing something wrong because this code doesn't work. Help!
    Last edited by MMcCarthy; Oct 6 '10, 07:48 PM. Reason: added code tags
  • Chris Lindsay

    #2
    figured it out!

    instead of:
    callFn();
    it should be:
    window[callFn]();

    Comment

    Working...