I have an image that sometimes returns a 404 error. To get the image to load, it usually works if the image src is slightly modified, for example adding "?reload=true" to the end of it. How do I do this using JavaScript?
<img src="example.com/image.png" onerror="reloadImage()">
<script>
function reloadImage() {
// Set img src to "example.com/image.png?reload=true"
}
</script>
thisas an agument toreloadImage, and dothisArg.src = "example.com/image.png?reload=true"in the function.srcproperty of the image is read/write string.