title: Javascript - onClick event
body: <p>So I currently have an image on a canvas and I want the page to reload once you click the image. The problem is that the page is reloading as soon as the "Go" function is called and not when the click event is initiated. Here is the bit of code.</p>
  
  <pre><code>function Go()
  {
      myimage = new Image();
      myimage.src = "http://i.imgur.com/xcLDp.gif";
  
      ctx.drawImage(myimage, 294, 100);
  
      myimage.onClick = window.location.reload();
  }
  </code></pre>
  
  <p>I feel like I'm missing something trivial, any help would be appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>Regards,</p>
  
  <p>Matt</p>
  
  <p>Edit: Added for Derek.</p>
  
  <blockquote>
    <p>Hey Derek I really appreciate the help. I'm going to be real
    noob with you for a second as I'm pretty new to coding. So I'm trying
    to implement the demo code you've shown me on my test website
    <a href="http://imstupid.net/matt/sq/test/jquery.html" rel="nofollow">here</a> but the error I
    get back is "Uncaught ReferenceError: $ is not defined".</p>
    
    <p>Now what I know is that "$" is a jQuery symbol, now I'm pretty new to
    coding/javascript in general so just imagine how new I am to javascript
    libraries (jQuery). </p>
    
    <p>I've downloaded jQuery and put it in the same directory then added
    this line to the html:</p>
  </blockquote>
  
  <pre><code>&lt;script src="jquery-1.7.2.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <blockquote>
    <p>Am I doing something wrong? Why is it not picking up on the jquery
    library?</p>
  </blockquote>