1

When the user visits my html page using the mobile browser, I want to know the device type and manufacturer. Is it possible?

If you open the web site www.mhltech.org/DoIHaveMHL.aspx from a mobile browser, it will identify the mobile device (like Motorola Moto G 2nd Gen 2014, Asus Google Nexus 7, etc.). It is what I am looking for.

raghu
  • 388
  • 3
  • 10
  • Did you do any research? E.g. http://webmasters.stackexchange.com/questions/1941/mobile-phone-detection-brand-model-browser-etc – jonrsharpe Jan 16 '17 at 07:46
  • I have done some search on the internet. Most of the solutions talk about identifying the mobile browser (through user agent). I was looking for specific brand and model. I missed the discussion mentioned by @jonrsharpe . It mentions some of the third party solutions. – raghu Jan 16 '17 at 11:36

3 Answers3

2

Perhaps you can use platform.js.

You can use platform.manufacturer; to solve your problem.

ajbee
  • 3,511
  • 3
  • 29
  • 56
  • I was looking for a way to find the device brand and model, not a third part solution. I have went through the platform.js, could make out the logic they were using. – raghu Jan 16 '17 at 11:40
2

In my case ua-parser-js was the best free solution. The minified version is on https://github.com/faisalman/ua-parser-js/tree/master/dist

What you need to do then is like

<script src="ua-parser.min.js" charset="utf-8"></script>
<script type="text/javascript">

var parser = new UAParser();
var result = parser.getResult();
alert(result.device.vendor);

</script>

I have tried platform.js and mobile-detect.js before this one, but their detection range was too narrow for my application, as my own phone was an "Unknown Phone" for them.

HolyResistance
  • 594
  • 1
  • 8
  • 26
1

Well,

You can use window.navigator.userAgent,

It will tell you the Device and browser information like

[Mozilla/5.0 (Linux; Android 6.0.1; Samsung SM-G900H Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecho) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari537.36]

and you just need to extract the bracket value which you need, and you got the device info.

To explore visit:
https://developer.mozilla.org/en-US/docs/Web/API/Navigator http://blog.teamtreehouse.com/exploring-javascript-device-apis

nityanarayan44
  • 378
  • 5
  • 10
  • I am aware of userAgent. I was looking for a method to get the exact information about the brand and model of the device. – raghu Jan 16 '17 at 11:42
  • 1
    userAgent gives you all the information related with Browser/Device, for device info, Extract the first bracket information that contains the device [Brand, Model, OS, ...] – nityanarayan44 Feb 15 '17 at 11:28