global variables - Call JavaScript val using window object & object key pair -
okay, rather avoid using eval @ costs, i'm trying figure out alternative calling global function using window object method:
var time = new date(); var varname = time.getday(); var obj = {'eleid':'varname'}; (var key in obj) { var vn = obj[key]; eval(vn); //this works window[vn]; //this doesnt work }
you've named function object, phone call it:
window[vn](); javascript global-variables window-object
No comments:
Post a Comment