title: execute javascript from textarea
body: <p>I'm not entirely sure if this is possible, but I'm trying to create a mini faux editor in a browser that runs javascript on the page. Here's what I've been trying to do in theory</p>
  
  <p>HTML</p>
  
  <pre><code>​&lt;textarea id="cnsl"&gt;&lt;/textarea&gt;
  &lt;button onclick="run()"&gt; run &lt;/button&gt;
  </code></pre>
  
  <p>javascript</p>
  
  <pre><code>var cnsl = document.getElementById('cnsl');
  
  function run() {
      return cnsl.value
  }
  </code></pre>
  
  <p>more specifically I'm trying to write to a canvas element via the 'code' I type into the text area, so that if, for example, i type ctx.fillRect(10,10,10,10); into my textarea and then execute that run() function the 10x10 square will appear in my canvas. </p>
  
  <p>I had a little luck when instead of returning the cnsl.value I wrote it to the innerHTML of an empty script element in my HTML. But this would only work the first time I'd execute the function and then won't work again until I refresh the page. (for example this: <a href="http://jsfiddle.net/ur5KC/1/" rel="noreferrer">http://jsfiddle.net/ur5KC/1/</a> which doesn't seem to work on jsfiddle but works locally as I described above)</p>
  
  <p>...any ideas??? thnx in advance!</p>