this let's me load a picture to my html tag. I would like to add a button and input text box in my html so that i can change the image by putting url. I tried to use put the onclick function in "head" but failed.
// what i tried
document.getElementById('url').onclick = function() {
img.src=document.getElementById('picUrl').value;
}
//what i have
<head>
var img=new Image();
img.onload=function(){
ctx.drawImage(img,0,0);
}
img.src="xxxx";
}
</head>