admin管理员组文章数量:1415467
How would I create 3 more scripts with regex that would check if the android is a certain version. I provided a sample ua header from a android version 2.2.
scripts needed
android 2.2.3 and below check
android 2.3 to 2.3.7 check
android 3.0 and above check
android ua string example:
Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
based off of this script
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1;
How would I create 3 more scripts with regex that would check if the android is a certain version. I provided a sample ua header from a android version 2.2.
scripts needed
android 2.2.3 and below check
android 2.3 to 2.3.7 check
android 3.0 and above check
android ua string example:
Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
based off of this script
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1;
Share
Improve this question
asked Feb 15, 2012 at 20:36
BlainerBlainer
2,71210 gold badges38 silver badges40 bronze badges
1 Answer
Reset to default 6Just off the top of my head, how about something like this:
var isAndroid = /android/i.test(ua);
var isGingerbread = /android 2\.3/i.test(ua);
var isHoneybOrNewer = /android [3-9]/i.test(ua);
var isFroyoOrOlder = isAndroid && !isGingerbread && !isHoneybOrNewer;
本文标签: jqueryandroid javascript regex detectionStack Overflow
版权声明:本文标题:jquery - android javascript regex detection - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745153137a2645008.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论