I'm interested in knowing the limits of JavaScript's eval
method.
eval("console.log('This is a test')");
will work as expected, printing the text This is a test
in the browser's dev-console.
But what about this code:
eval("jQuery(window).on('load', function(){ console.log('This is a test'); });");
Would that cause the browser to print the text after the page is loaded?
What about using jQuery's globalEval
? Would that make any difference?
Regards
EDIT: I'm doing some tests using this: https://stackoverflow.com/a/745386/940158
Even after eval
ing the jQUery code, the handler doesn't show up when I do $.eventReport(window)
, which makes me believe that eval
is failing at some point.