How to detect mobile safari browser in ios 7?

2019-04-19 05:47发布

问题:

What is the official method to detect mobile safari on ios7?

For example:

 navigator.userAgent.match(/(iPod|iPhone|iPad)/) 
 && navigator.userAgent.match(/AppleWebKit/) 
 && navigator.userAgent.match(/OS 7/)

回答1:

Try this (to detect iPod touch as well):

navigator.userAgent.match(/(iPad|iPhone|iPod touch);.*CPU.*OS 7_\d/i)


回答2:

Try this

navigator.userAgent.match(/(iPad|iPhone);.*CPU.*OS 7_\d/i)


回答3:

/iP(ad|hone|od)/.test(navigator.userAgent)

Gives simple T/F.