js判断ios版本是否是13.4.几的
时间: 2023-12-11 08:01:59 浏览: 48
方法一:
```
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 特定的代码逻辑
}
```
判断ios是否安装app window.location.href = ur 404
很抱歉,我无法提供关于具体代码的实时判断。但是,你可以使用JavaScript中的navigator对象来判断iOS设备是否安装了特定的应用程序。以下是一个示例代码:
```javascript
function isAppInstalled(scheme) {
var isInstalled = false;
if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
if (window.navigator.standalone) {
// 如果设备在主屏幕上添加了Web应用,window.navigator.standalone会返回true
isInstalled = true;
} else if (window.webkit) {
// 使用webkit尝试打开特定的URL scheme
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.src = scheme;
document.body.appendChild(iframe);
setTimeout(function() {
// 如果成功打开了URL scheme,则认为应用程序已安装
document.body.removeChild(iframe);
isInstalled = true;
}, 200);
}
}
return isInstalled;
}
// 使用例子
var isInstalled = isAppInstalled('myapp://');
console.log(isInstalled); // 返回true或false,表示应用是否已安装
```
请注意,这只是一种判断iOS设备上是否安装了应用程序的方法,并且需要在实际环境中进行测试和调整。