判断当前入口是PC端企业还是PC端浏览器。或者是APP端企业微信

在window.onLoad函数里使用

function isQyweixin(){
    
    
	//判断当前入口是PC端还是APP端
	 let flag = navigator.userAgent.match(
            /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
        )==null?false:true;

        return flag?is_weixin()?"来自于APP端企业微信":"":is_weixin()?"来自于PC端的企业微信":"来自于PC端浏览器";
}
function is_weixin(){
    
    
	 //判断是在企业微信打开 还是 在浏览器打开
     return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
}

猜你喜欢

转载自blog.csdn.net/weixin_39246975/article/details/108766402
今日推荐