Skip to content

Instantly share code, notes, and snippets.

@brianleroux
Created January 27, 2011 07:01
Show Gist options
  • Save brianleroux/798181 to your computer and use it in GitHub Desktop.
Save brianleroux/798181 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<title>isReachable Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", function() {
function reachableCallback(reachability) {
var state = reachability.code || reachability
, states = {}
states[NetworkStatus.NOT_REACHABLE] = 'No network connection';
states[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier connection';
states[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
alert('Connection type: ' + states[state]);
}
navigator.network.isReachable("phonegap.com", reachableCallback, {});
}, false);
</script>
</head>
<body>
<p>A dialog box will report the network state.</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment