我正在尝试运行phonegap连接代码。这是我的脚本,我已经安装了网络插件。
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady()
{
checkConnection();
}
function onBodyLoad() {
alert('body load');
checkConnection();
}
function checkConnection() {
networkState = navigator.connection.type;
alert('checkConnection');
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.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection';
alert('Connection type: ' + states[networkState]);
}
但我得到Uncaught TypeError: Cannot read property 'type' of undefined
。
任何人都可以建议我哪里出错了吗?
由于