Detect if device is iOS

前端 未结 17 1618
一整个雨季
一整个雨季 2020-11-22 01:39

I\'m wondering if it\'s possible to detect whether a browser is running on iOS, similar to how you can feature detect with Modernizr (although this is obviously device detec

17条回答
  •  逝去的感伤
    2020-11-22 02:09

    Slightly update the first answer using a more functional approach.

        const isIOS = [
          'iPad Simulator',
          'iPhone Simulator',
          'iPod Simulator',
          'iPad',
          'iPhone',
          'iPod',
        ].indexOf(navigator.platform) !== -1;
    

提交回复
热议问题