Tell iPadOS from macOS on the web

后端 未结 4 1504
南笙
南笙 2020-12-08 15:24

The user agent of Safari on iPadOS beta is at this point exactly the same as Safari on macOS. Is there any other way to tell an iPad from a Mac?

iPad running         


        
4条回答
  •  误落风尘
    2020-12-08 15:54

    I'm using this test client side:

       if (navigator.userAgent.match(/Mac/) && navigator.maxTouchPoints && navigator.maxTouchPoints > 2) {
         ...must be iPad OS...
    

    Since there's no official touch screen for Mac, it seems pretty safe. The actual value of maxTouchPoints on the iPad is 5, BTW.

提交回复
热议问题