简体   繁体   中英

Detect if Browser is Samsung Phone

Has anyone figured out a good way to detect if the client's browser is a Samsung phone. I'm specifically looking for Samsung S3 And Note 2, but if it catches S2 and Note 1 or other Samsung phones I can live with that. Something that is future proof (ie likely to work with S4 / Note3 is obviously ideal).

There seems to be no straight-forward way to do this like there is with iPhones, but with the large S3 and Note2 user base we would like to customize for those devices.

I'm aware that not all S3's have the same user agent (http://stackoverflow.com/questions/11282944/what-is-the-samsung-s3-user-agent)

And if someone has set there phone to PC version then I don't expect to catch these (http://stackoverflow.com/questions/11597940/android-phone-browser-detection)

I realize this is likely a problem with no good solution.

Detect Samsung Phone or Tablet default browser

if(navigator.userAgent.match(/SAMSUNG|SGH-[I|N|T]|GT-[I|P|N]|SM-[N|P|T|Z|G]|SHV-E|SCH-[I|J|R|S]|SPH-L/i))  {
    alert("it's Samsung default browser");
    // your code for Samsung goes here
}

This regex covers almost all Samsung mobile devices except Samsung Galaxy Nexus , Please verify.

It's obviously very hard to detect only a Samsung phone, but if you check here , and check back to the User Agent question in your question here , you'd notice that the User Agent depends on the phone model.

Limiting to just the GS3, there are plenty of model numbers, such as GT-I9300[T], SHV-E210K/L/S, SGH-T999[v], SGH-I747[m], SGH-N064 (SC-06D), SCH-R530, SCH-I535, SPH-L710, GT-I9305[T], GT-I9308

I'm not a web developer, I'm not sure how you would go about detecting that certain part of the User Agent, but if you can adapt your code for every model of the GS3, I'm assuming that would work well. Same goes with the model numbers of the Note 2, and when they come out, the GS4/Note 3.

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