I want to load/replace an image at a defined location. It works with "onclick" but it doesn't work with "onload". It seems to be linked with the problem CORS (I use firefox), but I don't know how to change in my code.
The html code works well with:
<img id="demo" onclick="loadImg()" src="css/images/movie5.jpg" width="100" height="232">
But it doesn't work with:
<img id="demo" onload="loadImg()" src="css/images/movie5.jpg" width="100" height="232">
Where my function loadImg():
<script>
function loadImg() {
document.getElementById("demo").src = "css/images/movie2.jpg";
}
</script>
Someone can give me a solution?