var broser = window.navigator.userAgent.toLowerCase(); //通过正则表达式匹配broser 中是否含有MicroMessenger字符串 if(broser .match(/MicroMessenger/i) == 'micromessenger'){ console.log('微信浏览器') }