所以我现在有一个画布上的图像,我希望页面重新加载,一旦你点击图像。问题在于,只要调用“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中的任何地方,你怎么点击它? –