Juriy Zaytsev wrote:
> In a nutshell, if one wanted to create a function object out of a string
> value of intrinsic event attribute, something along these lines would
> need to be used (for a more or less complete emulation):
>
> function eventHandlerFromAttr(element, attrValue){
> return function(e){
> with(document){
> with(element){
> var fn = eval('(function(event){' + attrValue + '})');
This is eval'ing in the current lexical context. You want a global eval.
In ES5:
var evil = eval;
var fn = evil('(function(event){' + attrValue + '})');
> return fn.call(element, e);
> }
> }
> }
> }
--
David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss