How to tell if the Windows is a PC or a tablet?

such as the title: now many tablets also use Windows10,. I want to check whether users are using tablets or PC computers, and ask for advice on PHP, Node and JS.

Apr.03,2021

JS: navigator.userAgent
you press F12 to enter navigator.userAgent directly in the console. My computer will display a string with Windows, and a mobile phone will display a string with Android.
my two pictures here are all the information of navigator.

     let list = [];
    for (let o in navigator) {
        list.push(<div>{o + '=' + navigator[o]}</div>);
    }

    return (
        <div>{list}</div>
    );

the simplest way is to judge


if ((navigator.userAgent.match (/ (phone | pad | pod | iPhone | iPod | ios | iPad | Android | Mobile | IEMobile | MQQBrowser | JUC | Fennec | wOSBrowser | BrowserNG | WebOS | Symbian | Windows Phone) / I) {
alert ('mobile end')
} else {
alert ('PC side')
}


Useragent analysis tool. Browser Analysis and judgment tool-user Agent, operating system Information

Code address: https://github.com/mumuy/browser

Menu