<script type="text/javascript"> var ua = navigator.userAgent.toLowerCase(); if (/iphone|ipad|ipod/.test(ua)) { //alert("iphone"); } else if (/android/.test(ua)) { //alert("Android"); } </script>…
function detect(){ var equipmentType = ""; var agent = navigator.userAgent.toLowerCase(); var android = agent.indexOf("android"); var iphone = agent.indexOf("iphone"); var ipad = agent.indexOf("ipad"); if(android !=…
每个客户端都带有自身的UA标识,通过JavaScript,可以获取客户端标识,我们可以获取浏览器的userAgent,用正则来判断手机是ios(苹果)还是Android(安卓)客户端. 项目实例:https://github.com/ght5935/phone 一:通过判断浏览器的userAgent <script type="text/javascript"> var u = navigator.userAgent; var isAndroid = u.indexOf('…