标签:window 版本 log cas iphone ipad weixin ipo 手机
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { //alert(navigator.userAgent); window.location.href ="iPhone.html"; } else if (/(Android)/i.test(navigator.userAgent)) { //alert(navigator.userAgent); window.location.href ="Android.html"; } else { window.location.href ="pc.html"; };
//新浪weibo客户端返回1,qq客户端返回2,微信小于6.0.2版本返回3,微信大于等于6.0.2版本返回4,其它返回0
var ua = navigator.userAgent.toLowerCase(); if(ua.match(/weibo/i) == "weibo") { return 1; } else if(ua.indexOf(‘qq/‘) != -1) { return 2; } else if(ua.match(/MicroMessenger/i) == "micromessenger") { var v_weixin = ua.split(‘micromessenger‘)[1]; v_weixin = v_weixin.substring(1, 6); v_weixin = v_weixin.split(‘ ‘)[0]; if(v_weixin.split(‘.‘).length == 2) { v_weixin = v_weixin + ‘.0‘; } if(v_weixin < ‘6.0.2‘) { return 3; } else { return 4; } } else { return 0; }
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) { alert("您是手机登录"); } else { alert("您是电脑登录"); }
标签:window 版本 log cas iphone ipad weixin ipo 手机
原文地址:http://www.cnblogs.com/janny-Du/p/7779297.html