<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>
我正在尝试使用 html 代码检查网络连接。如果我在本地机器上的 crome 上运行此代码,它可以工作,但为什么它不能在 android 上工作。