微信浏览器检测方法

我们可以用下面的代码来判断是在微信上打开的链接:

function is_weixin(){
                var ua = navigator.userAgent.toLowerCase();
                if(ua.match(/MicroMessenger/i)=="micromessenger") {
                        return true;
                 } else {
                        return false;
                }
            }

如果是微信浏览器可以做相应的提示信息。

个人网站:http://shibowl.top
github:https://github.com/hanbinjxnc
博客园:https://www.cnblogs.com/hool
个人博客:https://blog.shibowl.top
作者:世博 2019年4月28日
原文地址:https://www.cnblogs.com/hool/p/11037815.html