https://developers.google.com/chrome/mobile/docs/user-agent

GoogleChromeforAndroid

GoogleChrome

GoogleChromeforAndroid

Documentation

Overview

RemoteDebugging

UserAgent

FAQ

ChromeforAndroidUser-Agent

ChromeforAndroidreportsitsuseragentstring(UA)inthefollowingformats,dependingonwhetherthedeviceisaphoneoratablet:

PhoneUA:

Mozilla/5.0(Linux;<AndroidVersion>;<BuildTagetc.>)

AppleWebKit/<WebKitRev>(KHTML,likeGecko)Chrome/<ChromeRev>Mobile

Safari/<WebKitRev>

TabletUA:

Mozilla/5.0(Linux;<AndroidVersion>;<BuildTagetc.>)

AppleWebKit/<WebKitRev>(KHTML,likeGecko)Chrome/<ChromeRev>

Safari/<WebKitRev>

Here'sanexampleoftheChromeuseragentstringonaGalaxyNexus:

Mozilla/5.0(Linux;Android4.0.4;GalaxyNexusBuild/IMM76B)

AppleWebKit/535.19(KHTML,likeGecko)Chrome/18.0.1025.133Mobile

Safari/535.19

Forcomparison,hereareexamplesofotherpopularuseragentstrings:

DesktopChrome:Mozilla/5.0(Macintosh;IntelMacOSX10_7_3)AppleWebKit/535.19(KHTML,likeGecko)Chrome/18.0.1025.151Safari/535.19

DesktopSafari:Mozilla/5.0(Macintosh;IntelMacOSX10_7_3)AppleWebKit/534.53.11(KHTML,likeGecko)Version/5.1.3Safari/534.53.10

iPhoneSafari:Mozilla/5.0(iPhone;U;CPUlikeMacOSX;en)AppleWebKit/420+(KHTML,likeGecko)Version/3.0Mobile/1A543Safari/419.3

iPadSafari:Mozilla/5.0(iPad;U;CPUOS3_2likeMacOSX;en-us)AppleWebKit/531.21.10(KHTML,likeGecko)Version/4.0.4Mobile/7B334bSafari/531.21.10

FormoreinformationaboutMobileSafariuseragentstrings,seethisarticle.

Useragentmechanics

Likeallotherbrowsers,ChromeforAndroidBetasendsthisinformationintheUser-AgentHTTPheadereverytimeitmakesarequesttoanysite.It’salsoavailableintheclientthroughJavaScriptusingthenavigator.userAgentcall.

Ifyouareparsinguseragentstringsusingregularexpressions,thefollowingcanbeusedtocheckagainstChromeforAndroidphonesandAndroidtablets:

Phonepattern:'Android'+'Chrome/[.0-9]*Mobile'

Tabletpattern:'Android'+'Chrome/[.0-9]*(?!Mobile)'

相关推荐