I would like to run my html5 web application as follow:

If the mobile device is on Ethernet (WLan) then the web app should run as online, else when it's on cellular (G4,G3, Edge) then it's should run as offline.

I tried it with navigator.online, but this is not that for what i'm looking...

Is there a way to do this like this way?

thanks in adwance