获取网页是否在微信内置浏览器中打开,及判定操作系统是安卓还是IOS

		**判定是否是微信端打开的**
		var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == 'micromessenger') {
            return true;     //是微信端
        } else {
        	return false;    //不是微信端
		}

        **判定app下载,及操作系统是安卓ios**
        var u = navigator.userAgent, app = navigator.appVersion; 
		var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1;//g 
		var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);   //ios终端 
		if (isAndroid) {
		 	 console.log('这是安卓')
		        window.location.href = "安卓下载地址";
		       
		   } 
		if (isIOS) { 
		    	console.log('这是ios')
		    	window.location.href = "IOS下载地址"
		}

你可能感兴趣的:(js,IOS安卓)