秋痕语录

js判断是否从qq\微信浏览器打开网页

QQ截图20180930165040.jpg

废话不说直接上代码

function?isWeiXin()?{
????var?ua?=?navigator.userAgent.toLowerCase();
????if(ua.match(/MicroMessenger/i)?==?"micromessenger"?||?ua.match(/WeiBo/i)?==?"weibo")?{????
????????console.log('我是从微信打开的')
????????return?true;??
????}?else?if(ua.indexOf('mqqbrowser')?>?-1)?{?
????????console.log('我是从安卓qq打开的')
????????return?true;?
????}?else?if(ua.indexOf('iphone')?>?-1?||?ua.indexOf('mac')?>?-1)?{???
????????if(ua.indexOf('qq')?>?-1)?{?
????????????console.log('我是从IOSqq打开的')
????????????return?true;?
????????}
????}
????return?false;
}


打赏

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

?2017 Lxy 豫ICP备17013024号
Copyright2017 lixueyang All Rights Reserved

公告

Welcome to my blog, where you will experience the thrill of not exceeding