iOS Chrome detection

后端 未结 4 1507
情书的邮戳
情书的邮戳 2020-12-23 16:33

I use Javascript code

if( (Android|webOS|iPhone|iPad|iPod|BlackBerry).test(navigator.userAgent) ) {}

for mobile device detection, but Chrom

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 17:10

    According to Google Developers, the UA string looks like this:

    Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3
    

    Where it differs from iOS Safari in that it says CriOS instead of Version. So this:

    if(navigator.userAgent.match('CriOS'))
    

    Should do it.

提交回复
热议问题