js to determine whether it is a pc or a mobile terminal

I connected with the bank interface today, and found that the PC page could not be clicked, because the other party only made the mobile terminal, and the PC side did not do any processing. I need to pass parameters to them to determine whether it is the mobile terminal or the PC terminal. Because it turned out that when WeChat Alipay paid, it was judged whether it was a WeChat browser. If yes, use WeChat to pay, and if not, use Alipay to open it. The code is as follows:

 if (ua.match(/MicroMessenger/i) == 'micromessenger') {
//This is opened by WeChat browser
                            } else {

this is another browser

}

Today, I will make up for the judgment of whether it is a mobile terminal or a PC terminal. The code is as follows:

 if (navigator.userAgent.match(/Android/i) || (navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {
                    //这是移动端
                } else {
                    alert("PC端");
                }



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326018459&siteId=291194637