<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script>
<script type="text/javascript" charset="utf-8">
function load()
{
checkConnection();
}
function checkConnection()
{
alert('0000');
var networkState = navigator.network.connection.type;
alert('111');
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.NONE] = 'No network connection';
alert('2222');
alert('Connection type: ' + states[networkState]);
//if (networkState != Connection.NONE){
// redirecting to index page
}
</script>
</head>
<body onload="load()">
</body>
</html>
大家好,我知道有很多用于检查互联网连接的示例,我希望这不会被视为重复发布。
我想知道为什么无法处理警报 111
有什么问题吗"var networkState = navigator.network.connection.type;"
但是,我主要参考http://docs.phonegap.com的编码
谁能告诉我哪里出了问题?
谢谢