所以我現在有一個畫布上的圖像,我希望頁面重新加載,一旦你點擊圖像。問題在於,只要調用「Go」函數就會重新加載頁面,而不是啓動單擊事件時。這是一點代碼。Javascript - onClick事件
function Go()
{
myimage = new Image();
myimage.src = "http://i.imgur.com/xcLDp.gif";
ctx.drawImage(myimage, 294, 100);
myimage.onClick = window.location.reload();
}
我覺得我失去了一些微不足道的東西,任何幫助將不勝感激。
謝謝。
問候,
馬特
編輯:增加了對德里克。
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 here but the error I get back is "Uncaught ReferenceError: $ is not defined".
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).
I've downloaded jQuery and put it in the same directory then added this line to the html:
<script src="jquery-1.7.2.js" type="text/javascript"></script>
Am I doing something wrong? Why is it not picking up on the jquery library?
請張貼剩下的代碼。 – j08691
圖像甚至沒有被添加到DOM中的任何地方,你怎麼點擊它? –