How do I execute JavaScript I get from the user via a text field, inside the console and get the browser's console's output directly with JavaScript and/or jQuery?
-
2@AnthonyGrist What's the risk here ?Denys Séguret– Denys Séguret2013-05-07 10:46:33 +00:00Commented May 7, 2013 at 10:46
-
1@AnthonyGrist: It all depends on what that code is doing. I wouldn't say jsFiddle or JSBin are a "pretty big security risk"elclanrs– elclanrs2013-05-07 10:48:27 +00:00Commented May 7, 2013 at 10:48
-
jsFiddle does exactly this.Chris Dixon– Chris Dixon2013-05-07 10:48:28 +00:00Commented May 7, 2013 at 10:48
-
@dystroy Actually, having thought about it some more, if they're not saving it then it's not going to be an issue.Anthony Grist– Anthony Grist2013-05-07 10:49:22 +00:00Commented May 7, 2013 at 10:49
-
possible duplicate of Can you programmatically access the Firebug console output? and similar onesBergi– Bergi2013-05-07 10:49:36 +00:00Commented May 7, 2013 at 10:49
|
Show 5 more comments
1 Answer
8 Comments
akash4eva
You shouldn't use
eval anywhere! It is considered as evil! Here, look at this - developer.mozilla.org/en-US/docs/JavaScript/Reference/…Sazid
Ok, but what does the eval() function is doing here? I also heard its evil-ness.
Denys Séguret
@akash4eva Stop propagating irrational fears.
eval is perfectly suited to this situation.elclanrs
eval is fine. It becomes evil when you take user input data into your application with eval. But evaluating user code with eval is totally fine.Benjamin Gruenbaum
Solid answer +1 op might also find this useful stackoverflow.com/questions/15409639/…
|