Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- calling & defining functions using funcName() vs. window['funcName']()


Fotiman - 3:50 pm on Jan 5, 2013 (gmt 0)


Correct. That's because funcName0 only exists within the scope of the anonymous function, whereas defining them using the window[] format explicitly sets them in the window's scope. If you call them using funcName0() as opposed to window['funcName0'](), they would work because of the closure that allows them to be in scope still.

I guess I'm a little confused about what exactly you're trying to accomplish. Is there a reason you want to call the functions using the window[] format?

Also, on the jsfiddle, there are multiple window objects for different frames (which may be why it works on your site but not on the jsfiddle).


Thread source:: http://www.webmasterworld.com/javascript/4533285.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com