1
!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連接類型這是我從 它給了我錯誤的ReferenceError官方的PhoneGap頁簡稱代碼:找不到變量:在文件連接PhoneGap的參考未找到錯誤
請幫我把它弄出來......
您正在使用phonegap構建來構建您的應用程序? – Suhas