PhoneGap Connection 确定设备网络连接状态api
说明:
该属性是确定设备网络连接状态和连接类型的快速方法。
支持的平台:
iOS
Android
BlackBerry WebWorks (OS 5.0或更高版本)
Windows Phone 7 ( Mango )
简单的范例:function checkConnection() {
var networkState = navigator.network.connection.type;
var states = {};
states= 'Unknown connection';
states = 'Ethernet connection';
states = 'WiFi connection';
states= 'Cell 2G connection';
states= 'Cell 3G connection';
states= 'Cell 4G connection';
states = 'No network connection';
alert('Connection type: ' + states);
}
checkConnection();
完整的范例:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>PhoneGap-NetWork</title>
<link rel="stylesheet" href="../jquery.mobile-1.1.1/jquery.mobile-1.1.1.css" />
<script src="../jquery.mobile-1.1.1/jquery.js"></script>
<script src="../jquery.mobile-1.1.1/jquery.mobile-1.1.1.js"></script>
<script type="text/javascript" charset="utf-8" src="../cordova-1.9.0.js"></script>
<script type="text/javascript">
$(document).ready(function(){
document.addEventListener("deviceready", myDeviceReadyListener, false);
});
function myDeviceReadyListener(){
var networkState= navigator.network.connection.type;
var states = {};
states= "未知网络";
states= "蓝牙网络";
states= "WIFI无线网络";
states= "2G网络";
states= "3G网络";
states= "4G网络";
states= "无网络";
$("#networkState .ui-btn-text").text(states);
}
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>PhoneGap实战</h1>
</div>
<div data-role="content">
<a href="#" data-role="button" id="networkState">网络获取中....</a>
</div>
<div data-role="footer">
<h4> </h4>
</div>
</div>
</body>
</html>
请问如何 获取当前设备的Ip app 发表于 2013-11-12 18:14
请问如何 获取当前设备的Ip
ip官网没有给提供接口 得自己写插件
页:
[1]