I need to be able to detect a missing image in JavaScript.

PHP on the server can't be used because the href is computed by JavaScript. 
Script that works when the file exists is:

```
Data_ID = _DataRow.getDataItem()["Data_ID"];// Picks up the ID of the data
   _HitJPG = document.getElementById("HitJPG");
JPGFileName = _DataRow.getDataItem()["JPGFileName"];
directory = JPGFileName.slice(0, 10);
directory = directory.replace(/-/g, "/");

_HitJPG.innerHTML = "<a href=http://77.88.99.54/data/" + directory + "/" + JPGFileName + " ><h3>JPG File for this Data </h3>" + JPGFileName + "</a>";

```

How can I detect a HTTP 404 code before I set the "InnerHTML" in the Div?