title: canvas getContext("2d") returns null
body: <p>I've tried this a few different ways, but I keep getting stuck with the same error. I've loaded an image to canvas before, but since I updated Safari a few days ago, I'm getting errors.</p>
  
  <p>I'll post what I have at the moment, but I've tried doing it with jQuery, html's onLoad property, etc.</p>
  
  <pre><code>var cvs, ctx, img;
  function init() {
     cvs = document.getElementById("profilecanvas");
     ctx = cvs.getContext("2d"); /* Error in getContext("2d") */
     img = document.getElementById("profileImg");
     drawImg();
  }
  
  function drawImg() {
     ctx.drawImage(img, 0, 0);
  }
  
  window.onload = init();
  </code></pre>
  
  <p>The IDs are correct and correspond to appropriate canvas and img tags. However, I keep getting <code>TypeError: 'null' is not an object (evaluating 'cvs.getContext')</code> and it doesn't seem to be getting any further. I'm sure it's some ID10T error, but I'm hoping someone can give me a clue as to what's causing this? Thank you.</p>
  
  <p>Edit:
  Okay, so this seems to work using <code>&lt;body onload="init()"&gt;</code> now. However, it only displays occasionally, and if I try to run <code>init()</code> off of <code>$(document).ready()</code> or <code>document.onload</code> I still have no luck, and receive the error. Any thoughts?</p>