title: Javascript set <canvas> to window size
body: <p>I am attempting to set a canvas element to the size of the current window.</p>
  
  <p>I did so successfully with jquery here:</p>
  
  <pre><code>function windowsize() {
      WIDTH = $("#canvas")[0].width = ($(window).width());
      HEIGHT = $("#canvas")[0].height = ($(window).height());
  
  }
  
  windowsize();
  </code></pre>
  
  <p>I cannot accomplish the same thing in plain javascript, I have as follows:</p>
  
  <pre><code>function windowsize(){
      var ctx = document.getElementbyID("canvas");
      ctx.canvas.width = window.innerWidth;
      ctx.canvas.height = window.innerHeight;
  }
  windowsize();
  </code></pre>
  
  <p>Here is a fiddle with the above: <a href="http://jsfiddle.net/Kinetic915/bWYy7/" rel="nofollow noreferrer">http://jsfiddle.net/Kinetic915/bWYy7/</a></p>
  
  <p>I was also using the following page as a reference:</p>
  
  <p><a href="https://stackoverflow.com/questions/1664785/html5-canvas-resize-to-fit-window">Resize HTML5 canvas to fit window</a></p>
  
  <p>Thanks!</p>