js判断pc端移动端,js判断微信浏览器

js判断pc端移动端,js判断微信浏览器

1.js判断pc端移动端

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(isMobile) {
		alert(1);
	} else {
		alert(2);
	}

2.js判断微信浏览器

var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
    } else {
        alert("false");
    }

猜你喜欢

转载自blog.csdn.net/weixin_40687883/article/details/80402965