<script type="text/javascript"> function isMobile1() { 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) { return true; } else { return false; } } function isMobile2() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPod"]; var flag = true; for(var v = 0; v < Agents.length; v++) { if(userAgentInfo.indexOf(Agents[v]) > 0) { flag = true; break; } } if(window.screen.width >= 768) { flag = false; } return flag; } function isWeChat() { var ua = navigator.userAgent.toLowerCase(); if(ua.match(/MicroMessenger/i) == "micromessenger") { return true; } else { return false; } } alert('当前' + (isMobile1() == true ? '是' : "不是") + "移动设备访问(isMobile1())"); alert('当前' + (isMobile2() == true ? '是' : "不是") + "移动设备访问(isMobile2():增加 屏宽大于768直接为pc)"); alert('当前' + (isWeChat() == true ? '是' : "不是") + "微信访问"); </script>
有任何疑问或技术合作都可联系我
微信:yanfahezuo 【推荐】
QQ:596957738