Is there anyway to treat a string as a function name? To make something like this work(it doesn't)
Code:somestring = 'function_name'; window.onload = somestring function function_name(){ }
Is there anyway to treat a string as a function name? To make something like this work(it doesn't)
Code:somestring = 'function_name'; window.onload = somestring function function_name(){ }
Not quite. However, when you define a global function or variable, it becomes a property of the global object. From here, you can access it by its name using the ECMAScript objects-as-associative-arrays idea:Code:var somestring = 'function_name'; window.onload = window[somestring]; function function_name(){}
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Thanks Twey! Exactly what I was looking for.
Bookmarks