title: How to add a html5 CANVAS within a DIV
body: <p>I'm using the below code to generate a <code>canvas</code>.  At the moment it adds the canvas element to the <code>body</code>, how can I get it to add it to a <code>div</code> named "divGameStage", which is not nested within any other elements, except <code>body</code>.</p>
  
  <p>EDIT: I've tried the first suggestion, but no canvas is appearing, full code is as follows:</p>
  
  <pre><code>&lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Game Stage&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
      function loadCanvas(id) {
          var canvas = document.createElement('canvas');
          div = document.getElementByID(id); 
          canvas.id     = "CursorLayer";
          canvas.width  = 1224;
          canvas.height = 768;
          canvas.style.zIndex   = 8;
          canvas.style.position = "absolute";
          canvas.style.border   = "1px solid";
          div.appendChild(canvas)
      }
          &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;header&gt;
      &lt;h1&gt;The most important heading on this page&lt;/h1&gt;
      &lt;p&gt;With some supplementary information&lt;/p&gt;
  &lt;/header&gt;
  &lt;div id="divControls"&gt;&lt;/div&gt;
  &lt;div id="divGameStage"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      loadCanvas(divGameStage);
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>