I've got a script which displays an alert showing whether an image has been located or not, but I'm looking to prevent a false positive from the image being cached by the browser.
Usually I add something like "http://192.168.8.1/images/ping2.jpg"+"?rand="+randomNum;
to add a random number but I'm finding this is not working with this implementation.
<script> function pingImage(URL) {
var tester=new Image();
tester.onload=imageFound;
tester.onerror=imageNotFound;
tester.src=URL;
}
function imageFound() {
alert('That image is found and loaded');
}
function imageNotFound() {
alert('That image was not found.');
}
pingImage("http://192.168.8.1/images/ping2.jpg");
</script>