简体   繁体   中英

How to detect and display what mobile device user is using on a webpage?

When users land on my page, I would like to present them with a text saying

"You are using {device name}."

So for someone on a Samsung Galaxy 7 it would be:

"You are using the Samsung Galaxy 7."

What is the best way to go about this to display this in my page please?

Thanks

In order to get android device name you have to add only a single line of code:

android.os.Build.MODEL;

Found here: getting-android-device-name

If you are looking for a javascript solution, use wurfl.js https://web.wurfl.io/#wurfl-js

Include the js file and access the returned object to check if it's a phone.

From my phone, it's as follows.

{
    "is_mobile": true,
    "complete_device_name": Motorola MotoG3,
    "form_factor": Smartphone
}

Here is another solution in Js, No registration is needed.

And I don't think you will be able to get the device details, unless you are going native. You will only be able to detect, if the browser is mobile and which type of browser it is.

Hope this helps.

现在,我已经尝试过: https : //frubil.info/

console.log(FRUBIL.device.marketname); // Galaxy S7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM