I have searched through StackOverflow and have seen various topics on how to do this, but nothing that really pertains to my particular situation. I am writing (for a class)
Using window.navigator.onLine is inherantly unreliable, because the user might be connected to a network, but that network could not have internet access.
However, here is a barebones example
Online status
The network is: (state unknown)
See the fiddle in action: http://jsfiddle.net/3rRWK/