Search code examples
javascriptphphtmlnavigator

Navigator.userAgent.match - specific handset identification


I'm recognising when a user is using certain phones using navigator.userAgent.match but with Android there are many tablets/phones/set-top boxes. So I've got

if(navigator.userAgent.match(/android/i)){

But how would I specifically then select a HTC One S from the list of Androids? It's user agent is:

user-agent: Mozilla/5.0 (Linux; U; Android 4.0.3; en-gb; HTC_One_S Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

I can say Android 4.0 but then there are a lot of products with Android 4.0. Next step would be to check the screen size, which I can do, but is there a way to specifically just check if the navigator.userAgent matches EXACTLY a HTC One S?


Solution

  • Maybe if(navigator.userAgent.match(/HTC_One_S/i)){ ?