【发布时间】:2014-05-05 23:16:51
【问题描述】:
!DOCTYPE html>
<html>
<head>
<title>navigator.connection.type Example</title>
<script type="text/javascript" charset="utf-8" src="js/libs/cordova-2.0.0.js"></script>
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
checkConnection();
}
function checkConnection() {
var networkState = navigator.connection.type;
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('Connection type: ' + states[networkState]);
}
</script>
</head>
<body>
<a href="#" onclick="checkConnection();">Just</a>
</body>
</html>
我想在 android 手机上获取 Internet 连接类型 这是我从官方PhoneGap页面引用的代码 它给了我错误 ReferenceError: Can't find variable: Connection at file
请帮助我摆脱它...
【问题讨论】:
-
您正在使用 phonegap build 来构建您的应用程序?
标签: android cordova compiler-errors cordova-2.0.0