动态调用JS方法的几种方法 (dynamically call js funtions)

访问量: 1145

say_hi =function(){
  alert('hi')
}

# refer to: http://stackoverflow.com/questions/969743/how-do-i-call-a-dynamically-named-method-in-javascript
1. window['say_hi']() #global method

# refer to : http://stackoverflow.com/questions/15202942/javascript-dynamic-function-call-with-name
2. this['say_hi']() # defined in some namespace

# http://viralpatel.net/blogs/calling-javascript-function-from-string/
3. eval("say_hi()")

订阅/RSS Feed

Subscribe

分类/category