function getOS() { // 获取当前操作系统    var os;    if (navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Linux') > -1) {        os = 'Android';    } else if (navigator.userAgent.indexOf('iPhone') > -1) {        os = 'iOS';    } else if (navigator.userAgent.indexOf('Windows Phone') > -1) {        os = 'WP';    } else {        os = 'Others';    }    return os;}function getOSVersion() { // 获取操作系统版本    var OSVision = '1.0';    var u = navigator.userAgent;    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //Android    var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端    if (isAndroid) {        OSVision = navigator.userAgent.split(';')[1].match(/\d+\.\d+/g)[0];    }    if (isIOS) {        OSVision = navigator.userAgent.split(';')[1].match(/(\d+)_(\d+)_?(\d+)?/)[0];    }    return OSVision;}function getOrientationStatu() { // 获取横竖屏状态    var orientationStatu;    if (window.screen.orientation.angle == 180 || window.screen.orientation.angle == 0) { // 竖屏        orientationStatu = '竖屏';    }    if (window.screen.orientation.angle == 90 || window.screen.orientation.angle == -90) { // 横屏        orientationStatu = '横屏';    }    return orientationStatu;}function getDeviceType() { // 获取设备类型    var deviceType;    var sUserAgent = navigator.userAgent.toLowerCase();    var bIsIpad = sUserAgent.match(/(ipad)/i) == "ipad";    var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";    var bIsMidp = sUserAgent.match(/midp/i) == "midp";    var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";    var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";    var bIsAndroid = sUserAgent.match(/android/i) == "android";    var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";    var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";    if (!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) {        deviceType = 'PC'; //pc    } else if (bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {        deviceType = 'phone'; //phone    } else if (bIsIpad) {        deviceType = 'ipad'; //ipad    } else {        deviceType = '未知';    }    return deviceType;}function getNetWork() { // 获取网络状态    var netWork;    switch (navigator.connection.effectiveType) {        case 'wifi':            netWork = 'wifi'; // wifi            break;        case '4g':            netWork = '4G'; // 4g            break;        case '2g':            netWork = '2G'; // 2g            break;        case  '3g':            netWork = '3G'; // 3g            break;        case  'ethernet':            netWork = '以太网'; // ethernet            break;        case  'default':            netWork = '未知'; // 未知            break;    }    return netWork;}function createFingerprint(domain) { // 生成浏览器指纹    var fingerprint;    function bin2hex(s) {        var i, l, n, o = '';        s += '';        for (i = 0, l = s.length; i < l; i++) {            n = s.charCodeAt(i)                .toString(16);            o += n.length < 2 ? '0' + n : n;        }        return o;    }    var canvas = document.createElement('canvas');    var ctx = canvas.getContext('2d');    var txt = domain || window.location.host;    ctx.textBaseline = "top";    ctx.font = "14px 'Arial'";    ctx.textBaseline = "tencent";    ctx.fillStyle = "#f60";    ctx.fillRect(125, 1, 62, 20);    ctx.fillStyle = "#069";    ctx.fillText(txt, 2, 15);    ctx.fillStyle = "rgba(102, 204, 0, 0.7)";    ctx.fillText(txt, 4, 17);    var b64 = canvas.toDataURL().replace("data:image/png;base64,", "");    var bin = atob(b64);    var crc = bin2hex(bin.slice(-16, -12));    fingerprint = crc;    return fingerprint;}

更多相关文章

  1. JS判断手机操作系统(ios或android)并跳转到不同下载页面
  2. 安卓自学,手机上的横竖屏切换,状态栏隐藏
  3. android之HttpPost&HttpGet使用方法介绍
  4. Android(安卓)获取网络状态的工具类
  5. android 2.3 电量管理
  6. android perimission 和 user-perimission
  7. Android(安卓)SwitchButton(滑动开关)
  8. Android(安卓)Jetpack架构组件(七)之WorkManager
  9. Android(安卓)USB状态监控(解决scheme="file")

随机推荐

  1. android开发架构设计学习
  2. android中实现带图片和checkbox的listvie
  3. android 圆角按钮和按钮颜色
  4. Android系统对应用程序权限申请的处理方
  5. Android(安卓)PVPlayer介绍
  6. Android的快速开发框架afinal
  7. Android(安卓)studio project文件结构翻
  8. android-apktool - A tool for reverse e
  9. Android中gravity与layout_gravity的区别
  10. 修改Android开机画面