Pick up the Android version in the browser by Javascript

后端 未结 9 1256
小蘑菇
小蘑菇 2020-12-02 05:09

I\'m building a web app and wanting to disable transitions effects on Android devices under version 3.0.

Is there anyway to pick up the Android version number by Ja

9条回答
  •  悲&欢浪女
    2020-12-02 06:01

    Use below code to get 2 digit version of Android

    var ua = navigator.userAgent;
    if( ua.indexOf("Android") >= 0 )
    {
      var androidversion = parseFloat(ua.slice(ua.indexOf("Android")+8)); 
      if (androidversion < 2.3)
      {
          // do whatever
      }
    }
    

    For example

    Mozilla/5.0 (Linux; U; Android 2.2.1; fr-ch; A43 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

    will return Android Version = 2.2

提交回复
热议问题