js判断手机系统和微信

mac2022-06-30  25

//判断手机浏览器

var ua = navigator.userAgent;

var ipad = ua.match(/(iPad).*OS\s([\d_]+)/),

isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),

isAndroid = ua.match(/(Android)\s+([\d.]+)/),

isMobile = isIphone || isAndroid;

if(isIphone || ipad){//如果是ios操作系统

  //要执行的代码片段

}else{

  //是安卓系统是要执行的代码片段

}

 

//判断是否是微信

function is_weixin(){

  var ua = navigator.userAgent.toLowerCase();

  if(/micromessenger/i.test(ua)){

    //是微信时要执行的代码

   }else{

    //不是微信时执行的代码  

     }

}

转载于:https://www.cnblogs.com/chengkun101/p/4566600.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)