How to detect the Internet connection is offline in JavaScript?
There are a number of ways to do this:
onerror
in an img
, like 
.This method could also fail if the source image is moved / renamed, and would generally be an inferior choice to the ajax option.
So there are several different ways to try and detect this, none perfect, but in the absence of the ability to jump out of the browser sandbox and access the user's net connection status directly, they seem to be the best options.