let image = new Image();
image.onerror = function () {
if (! image) return;
image = undefined;
alert("123.456.789.012 is ONLINE");
}
image.onload = image.onerror;
image.src = "http://123.456.789.012/123.jpg";
setTimeout(function () {
if (! image) return;
image = undefined;
alert("123.456.789.012 is OFFLINE"); }, 5000);
}
[1] 123.456.789.012 is a host, it could be online or offline. This script is designed to determine its status.
[2] The file named "123.jpg" does not exist in the system.
[3] I am struggling with understanding these three lines of code:
if (! img) return;
img = undefined;
alert("123.456.789.012 is ONLINE"); or alert("123.456.789.012 is OFFLINE");
Could someone clarify the purpose of these lines?