Tell iPadOS from macOS on the web

后端 未结 4 1493
南笙
南笙 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:55

    I'm using this works fine:

    const ua = window.navigator.userAgent.toLowerCase();
    const isiPad = ua.indexOf('ipad') > -1 || ua.indexOf('macintosh') > -1 && 'ontouchend' in document;
    

提交回复
热议问题