Determine whether to open a web page in WeChat's built-in browser

Problem Description

Since external links cannot be opened in the WeChat browser, if you want to click the button to download in the WeChat built-in browser, it will not be successful. At this time, we need to determine whether we are in the WeChat built-in browser and make different prompts.

As shown below:
Insert image description here

Code to determine whether WeChat has a built-in browser

const ua = window.navigator.userAgent.toLowerCase()
let isWeixin = ua.indexOf('micromessenger') != -1;
 if(isWeixin) {
    
    
     // 微信内置浏览器内的操作
 }else {
    
    
     // 普通浏览器内的操作
 }

Guess you like

Origin blog.csdn.net/u013558749/article/details/121531212