<html>
<head>
<title>Cordova Offline Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when Cordova is loaded.
//
// At this point, the document has loaded but cordova-1.9.0.js has not.
// When Cordova is loaded and talking with the native device,
// it will call the event `deviceready`.
//
function Network(){
if(navigator.onLine)
{
alert('You are Online');
}
else
{
alert('You are Offline')
}
}
</script>
</head>
<body >
<input type="button" value="Check Network" onclick="Network()" />
</body>
</html>
I am trying to check network connection using html code. It is working if i run this code on crome on my local machine but why it is not working on android.
it there are some phonegap specific events u have to use for some taks like internet connectivity checking issue
here is an example by which u can check internet connectivty
navigator.network.connection.type Example
A dialog box will report the network state.
for more detail have a look at this Connection