获取手机信息
程序员文章站
2022-04-03 09:13:27
...
// 操作系统类型
var systemType,myInfoIp,myInfoAddress,myInfoNetwork,myBrowser,myInfoPower,myInfoLon,myInfoLat;
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
//alert(navigator.userAgent);
systemType = 'IOS';
} else if (/(Android)/i.test(navigator.userAgent)) {
//alert(navigator.userAgent);
systemType = 'Android';
} else {
// console.log('这是PC');
systemType = 'PC';
};
//浏览器版本
function getBrowserInfo(){
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var re =/(msie|firefox|chrome|opera|version).*?([\d.]+)/;
var m = ua.match(re);
Sys.browser = m[1].replace(/version/, "safari");
Sys.ver = m[2];
return Sys;
}
var sys = getBrowserInfo();
myBrowser = sys.browser + " 版本:" + sys.ver;
// 分辨率
myInfoPower = screen.height + ' × ' + screen.height;
// ip / 地址 / 运营商
$.ajax({
type:"get",
url:"http://ip.chinaz.com/getip.aspx",/url写异域的请求地址/
dataType:"jsonp",/加上datatype/
jsonpCallback:"cb",/设置一个回调函数,名字随便取,和下面的函数里的名字相同就行/
success:function(e){
// console.log(e)
myInfoIp = e.ip;
var str = e.address;
var myInfo = str.split(" ");
myInfoAddress = myInfo[0];
myInfoNetwork = myInfo[1];
}
});
// 经纬度
var options = {
enableHighAccuracy: true,
timeout: 1000,
maximumAge: 1000
};
function success(pos) {
var crd = pos.coords;
alert('成功')
console.log('Your current position is:');
console.log('Latitude : ' + crd.latitude);
console.log('Longitude: ' + crd.longitude);
console.log('More or less ' + crd.accuracy + ' meters.');
};
function error(err) {
console.log('ERROR(' + err.code + '): ' + err.message);
};
navigator.geolocation.getCurrentPosition(success, error, options);
上一篇: 鸡肋的PHP单例模式应用详解_php实例
下一篇: Android -- 获取设备硬件信息