js获取手机信息
- <!DOCTYPE html>
- <html>
- <head lang="en">
- <meta charset="UTF-8">
- <title></title>
- <script src="js/jquery-2.1.4.min.js"></script>
- <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
- <script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
- </head>
- <body>
- <script language="javascript" type="text/javascript" src="http://pv.sohu.com/cityjson?ie=utf-8">
- </script>
- <script>
- var map;
- var gpsPoint;
- var baiduPoint;
- var gpsAddress;
- var baiduAddress;
- //ip ip地址 字符串
- //time 时间 单位秒
- //os 操作系统版本
- //platform 平台 android or ios
- //city 城市
- //location = {lng:XX,lnt:XX} 格式
- //brand 手机品牌
- /* var ip="192.168.1.24";//测试数据
- var time="2015/12/15 下午13:11";
- var os="android 4.4.3";
- var platform="android";
- var city="成都";
- var brand="DOA";
- var lng="250";
- var lnt="140";*/
- var ip;
- var time;
- var os;
- var platform;
- var city;
- var brand;
- var lng;
- var lnt;
- function getLocation() {
- String.prototype.trim = function () {
- return this.replace(/(^\s*)|(\s*$)/g, '');
- }
- var test1 = navigator.userAgent.toLocaleString().split("(");
- var test2 = test1[1].split(")")[0].split(";");
- if (test2[0] == "iPhone") {
- platform = "ios";
- brand = test2[0].trim();
- os = test2[1].split(" ")[3] + " " + test2[1].split(" ")[4].trim();
- } else {
- if (test1.length > 2) {
- var test2 = test1[1].split(")")[0].split(";");
- if (test2.length == 5) {
- os = test2[2].trim();
- //alert(test2[4].split(" ").length)
- platform = test2[2].split(" ")[1];
- //if(test2[4].split(" ")[0]==" "){
- //test2[4].split(" ")[1];
- //}
- if (test2[4].split(" ").length == 4) {
- brand = (test2[4].split(" ")[1] + " " + test2[4].split(" ")[2]).trim();
- } else {
- brand = (test2[4].split(" ")[0] + " " + test2[4].split(" ")[1]).trim();
- }
- }
- }
- }
- //时间格式化的方法
- /* Date.prototype.Format = function (fmt) { //author: meizz
- var o = {
- "M+": this.getMonth() + 1, //月份
- "d+": this.getDate(), //日
- "h+": this.getHours(), //小时
- "m+": this.getMinutes(), //分
- "s+": this.getSeconds(), //秒
- "q+": Math.floor((this.getMonth() + 3) / 3), //季度
- "S": this.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
- time = new Date().Format("yyyy-MM-dd hh:mm");*/
- var d = new Date();
- var sumS = d.getTime();
- time = sumS;
- //根据IP获取城市
- var myCity = new BMap.LocalCity();
- myCity.get(getCityByIP);
- /* alert("当前时间为" + myDate.toLocaleString());
- alert("操作系统版本" + navigator.platform)
- alert("设备其他信息:" + navigator.userAgent);*/
- }
- function showMap(value) {
- var longitude = value.coords.longitude;
- var latitude = value.coords.latitude;
- map = new BMap.Map("map");
- lng = longitude;
- lnt = latitude;
- gpsPoint = new BMap.Point(longitude, latitude); // 创建点坐标
- map.centerAndZoom(gpsPoint, 15);
- //根据坐标逆解析地址
- var geoc = new BMap.Geocoder();
- geoc.getLocation(gpsPoint, getCityByCoordinate);
- BMap.Convertor.translate(gpsPoint, 0, translateCallback);
- /* alert('ip' + ip);
- alert("时间" + time);
- alert('城市' + city);
- alert('操作系统' + os);
- alert('平台' + platform);
- alert("平台长度"+platform.length);
- alert('设备' + brand);
- alert('经度' + lnt)
- alert('纬度' + lng)*/
- $.ajax({
- type: "get",
- async: false,
- url: "http://192.168.1.34:27017" +
- "?ip="
- + encodeURIComponent(ip)
- + "&time=" + encodeURIComponent(time)
- + "&os=" + encodeURIComponent(os)
- + "&platform=" + encodeURIComponent(platform)
- + "&city=" + encodeURIComponent(city)
- + "&brand=" + encodeURIComponent(brand)
- + "&lng=" + encodeURIComponent(lng)
- + "&lnt=" + encodeURIComponent(lnt),
- dataType: "jsonp",
- jsonpCallback: "jsonpCallback",
- scriptCharset: 'UTF-8',
- success: function (data) {
- alert("测试成功")
- window.close();
- console.log(data);
- },
- error: function () {
- alert("测试成功")
- window.opener = null;
- window.open('', '_self');
- window.close();
- console.log('fail');
- }
- });
- function jsonpCallback(data) {
- alert("测试成功")
- window.close();
- console.log(data)
- }
- }
- translateCallback = function (point) {
- baiduPoint = point;
- var geoc = new BMap.Geocoder();
- geoc.getLocation(baiduPoint, getCityByBaiduCoordinate);
- }
- function getCityByCoordinate(rs) {
- gpsAddress = rs.addressComponents;
- var address = "GPS标注:" + gpsAddress.province + "," + gpsAddress.city + "," + gpsAddress.district + "," + gpsAddress.street + "," + gpsAddress.streetNumber;
- var marker = new BMap.Marker(gpsPoint); // 创建标注
- /* map.addOverlay(marker); // 将标注添加到地图中*/
- var labelgps = new BMap.Label(address, { offset: new BMap.Size(20, -10) });
- /* marker.setLabel(labelgps); //添加GPS标注*/
- }
- function getCityByBaiduCoordinate(rs) {
- baiduAddress = rs.addressComponents;
- var address = "百度标注:" + baiduAddress.province + "," + baiduAddress.city + "," + baiduAddress.district + "," + baiduAddress.street + "," + baiduAddress.streetNumber;
- /* alert("当前位置为" + address + "附近");*/
- var marker = new BMap.Marker(baiduPoint); // 创建标注
- map.addOverlay(marker); // 将标注添加到地图中
- var labelbaidu = new BMap.Label(address, { offset: new BMap.Size(20, -10) });
- marker.setLabel(labelbaidu); //添加百度标注
- }
- //根据IP获取城市
- function getCityByIP(rs) {
- var cityName = rs.name;
- ip = returnCitySN.cip;
- city = cityName;
- //获取GPS坐标
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(showMap, handleError, { enableHighAccuracy: true, maximumAge: 1000 });
- } else {
- alert("您的浏览器不支持使用HTML 5来获取地理位置服务");
- window.close();
- }
- var options = {
- enableHighAccuracy: true,
- maximumAge: 10
- }
- }
- function handleError(value) {
- switch (value.code) {
- case 1:
- alert("位置服务被拒绝");
- break;
- case 2:
- alert("暂时获取不到位置信息");
- break;
- case 3:
- alert("获取信息超时");
- break;
- case 4:
- alert("未知错误");
- break;
- }
- window.close();
- }
- function init() {
- getLocation();
- }
- window.onload = init;
- </script>
- <div id="map"></div>
- </body>
- </html>
js获取手机信息的更多相关文章
- 前端通过js获取手机型号
###前段通过js获取手机型号 需求: 用户登录后记录当前的手机型号并记录 插件: mobile-detect.js插件地址 mobile-device-js插件地址 使用步骤: 获取UA信息-> ...
- 微信小程序开发(六)获取手机信息
// succ.js var app = getApp() Page({ data: { mobileModel: '', // 手机型号 mobileePixelRatio: '', // 手机像素 ...
- JS获取手机型号和系统
废话不多说,直接上源码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type&q ...
- js get browser vertion (js获取浏览器信息版本)
1问题:js get browser vertion (js获取浏览器信息版本) 2解决方案 Copy this script into your JavaScript files. It works ...
- iOS 整理笔记 获取手机信息(UIDevice、NSBundle、NSLocale)
/* iOS的APP的应用开发的过程中,有时为了bug跟踪或者获取用反馈的需要自动收集用户设备.系统信息.应用信息等等,这些信息方便开发者诊断问题,当然这些信息是用户的非隐私信息,是通过开发ap ...
- 【风马一族_Android】Android 从命令行界面获取手机信息
Android 从命令行界面获取手机信息 1: cmd 打开命令行界面 2:adb devices 获取与电脑相连的设备,例如:模拟器.真机(手机) (右击“标记”,选择设备名称,点击“Ctrl+ ...
- Android 获取手机信息,设置权限,申请权限,查询联系人,获取手机定位信息
Android 获取手机信息,设置权限,申请权限,查询联系人,获取手机定位信息 本文目录: 获取手机信息 设置权限 申请权限 查询联系人 获取手机定位信息 调用高德地图,设置显示2个坐标点的位置,以及 ...
- android 获取手机信息工具类
package com.yqy.yqy_listviewheadview; import android.content.Context; import android.telephony.Telep ...
- android获取手机信息大全
IMEI号,IESI号,手机型号: private void getInfo() { TelephonyManager mTm = (TelephonyManager) getSystemServic ...
随机推荐
- 实战Google深度学习框架-C3-TensorFlow入门
第三章:TensorFlow入门 TensorFlow存在计算模型,数据模型和运算模型(本文用TF代表TensorFlow) 3.1 计算模型-计算图 3.1.1 计算图的概念 TensorFlow这 ...
- Pandas系列(十三)-其他常用功能
一.统计数据频率 1. values_counts pd.value_counts(df.column_name) df.column_name.value_counts() Series.value ...
- EF CodeFirst系列(9)---添加初始化数据和数据库迁移策略
1.添加初始化数据(Seed) 我们可以在初始化数据库的过程中给数据库添加一些数据.为了实现初始化数据(seed data)我们必须创建一个自定义的数据库初始化器(DB initializer),并重 ...
- [再寄小读者之数学篇](2014-10-18 利用 Lagrange 中值定理求极限)
试求 $$\bex \vlm{n}n^2\sex{x^\frac{1}{n}-x^\frac{1}{n+1}},\quad x>0. \eex$$ 解答: $$\beex \bea \mbox{ ...
- Javaweb学习笔记——(二十七)——————泛型、泛型的通配符、反射泛型信息、反射注解、注解
泛型 1.泛型类:具有一个或多个类型变量的类,称之为泛型类 class A<T>{ } 2.在创建泛型实例时,需要为其类型变量赋值 A<String> a = new ...
- 获取搜索结果的真实URL、描述、标题
1.场景 爬虫练手代码 2.代码 Python2: #!/usr/bin/python # -*- coding:utf-8 -*- import requests from lxml import ...
- Illegal invocation with document.querySelector [duplicate]
document.querySelectorAll赋给其它变量时, 为什么要.bind(document)? https://stackoverflow.com/questions/12637061/ ...
- C“控制”Lua
[前言] 写过Windows程序的人都知道,对于应用程序,如果需要在本地保存一些配置信息,我们经常将这些配置信息写在注册表或者本地的配置文件中,很多应用都是将一些配置信息写在配置文件中,比如以ini结 ...
- shim和polyfill
shim是将新的api引入旧的环境 polyfill是一段代码或插件 https://www.aliyun.com/jiaocheng/773254.html 理解得不够透彻...
- Java_Number(装箱和拆箱)
所有的包装类(Integer.Long.Byte.Double.Float.Short)都是抽象类Number子类 装箱: 自动将基本数据类型装换为包装器类型 拆箱: 自动将包装器类型转换为基本数据类 ...