function is_weixinOrAli(){ var ua = navigator.userAgent.toLowerCase(); //判断浏览器的类型 if (ua.match(/MicroMessenger/i) != "micromessenger" && ua.match(/Aplipay/i) != "aplipay") { // 如果不是微信内置浏览器,或支付宝内置浏览器,就动态跳转到以下页面 window.location.href = "http:www.baidu.com"; //window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxdf3f22ebfe96b912&redirect_uri=xxx&response_type=code&scope=snsapi_base&state=hyxt#wechat_redirect'; } }