js判断ios版本是否是13.4.几的
时间: 2023-12-11 20:01:59 浏览: 213
方法一:
```
const isIOS13_4 = () => {
const ua = navigator.userAgent;
const iosVersion = parseFloat(
('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(ua) || [0, ''])[1])
.replace('undefined', '3_2').replace('_', '.').replace('_', '')
);
return iosVersion === 13.4;
}
console.log(isIOS13_4()); // true or false
```
方法二:
```
const isIOS13_4 = () => {
const iosVersion = parseFloat(('' + (navigator.userAgent.match(/OS (\d+)_(\d+)_?(\d+)?/) || [0, 0, 0])[1] + '.' + (navigator.userAgent.match(/OS (\d+)_(\d+)_?(\d+)?/) || [0, 0, 0])[2]).replace(/\b0+/g, ''));
return iosVersion === 13.4;
}
console.log(isIOS13_4()); // true or false
```
相关问题
js判断ios版本是否是13的
方法如下:
```javascript
const isIos13 = () => {
const ua = navigator.userAgent;
const match = ua.match(/OS (\d+)_(\d+)_?(\d+)?/);
if (match !== null) {
const version = parseInt(match[1], 10);
return version === 13;
}
return false;
};
```
使用方式:
```javascript
if (isIos13()) {
// iOS 13 特定的代码逻辑
}
```
阅读全文