Executing Javascript from inside textarea (custom JS console)
问题 I am interested in building a text editor in a CMS backend that allows users to write Javascript into a textarea and test it while editing. The closest I can think of is something like. document.head.appendChild(document.createElement('script')).src='http://site.com/file.js'; But instead of .src='http://site.com/file.js'; I would need to fill the script element with the textarea value. Does anyone have any idea as how to handle something like this? 回答1: I have written a simple one of these