var a = "hello"; var b = " world"; var func = "function(param1, param2) { document.write(param1 + param2); document.write('<br />'); return 42; }"; document.write(eval(" ("+func+")(a, b) ")); // this one does it anonymously, not garbaging context with temp functions document.write('<br />'); var func2 = "function sub(param1, param2) { document.write(param1 + param2); document.write('<br />'); return 42; }"; onEvent(a, b); function onEvent(e, v) { var ff = eval(func2); sub.apply(this, arguments); // this one uses args explicitely }
Chapter X. In which our her0 enters waters of åNdroid (but not only) development while fulfilling his destiny which will never be known to anyone including those who's supposed to know it but for reason of their non-existence you're not reading this aren't you question mark.
Sunday, October 24, 2010
passing arguments to evaluated javascript (so you got a string to execute...)
Labels:
javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment