The Navigator Object

The onLine property returns true if the browser is online: