全球主机交流论坛

标题: 搞定了。 [打印本页]

作者: 全球VPS大学    时间: 2019-10-17 14:36
标题: 搞定了。
本帖最后由 全球VPS大学 于 2019-10-17 16:16 编辑

答案在楼下,两位大虾都已经回复了。
作者: image    时间: 2019-10-17 14:40
v=ver[1].replace(/_/g,".");

然后if判断v值 就行了
作者: 全球VPS大学    时间: 2019-10-17 14:44
image 发表于 2019-10-17 14:40
v=ver[1].replace(/_/g,".");

然后if判断v值 就行了

    var str= navigator.userAgent.toLowerCase();
    var ver=str.match(/cpu iphone os (.*?) like mac os/);
        v=ver[1].replace(/_/g,'.');
          if(v>=13.0){
         alert('大于13系统了');
    }
    else{
     alert('13系统以下了');
    }



运行的时候,不管是IOS12还是IOS13 ,都会 得到【13系统一下了】这个值
作者: image    时间: 2019-10-17 14:50
全球VPS大学 发表于 2019-10-17 14:44
var str= navigator.userAgent.toLowerCase();
    var ver=str.match(/cpu iphone os (.*?) like m ...

你对比的是string吧
转为数字
作者: image    时间: 2019-10-17 14:51
我只是告诉了你怎么写 具体的代码还是得自己写下。我手机上的不好码代码...
作者: image    时间: 2019-10-17 14:56
或者直接对比string是不是13开头的就行了 不用转数字对比具体的大小
作者: 全球VPS大学    时间: 2019-10-17 15:04
image 发表于 2019-10-17 14:56
或者直接对比string是不是13开头的就行了 不用转数字对比具体的大小

谢谢,搞好了
作者: idiotbaka    时间: 2019-10-17 15:09

  1. var str= navigator.userAgent.toLowerCase();
  2. var ver=str.match(/cpu iphone os (.*?) like mac os/);
  3. // 如果是IOS用户
  4. if(ver) {
  5.     // 获取版本号
  6.     var version = parseInt(ver[1].substring(0, ver[1].indexOf('_')));
  7.     if(version == 13) {
  8.         location.href = "www.baidu.com";
  9.     }
  10.     else {
  11.         location.href = "www.sogou.com";
  12.     }
  13. }
复制代码

作者: 全球VPS大学    时间: 2019-10-17 16:16
idiotbaka 发表于 2019-10-17 15:09

谢谢
作者: jiajieit    时间: 2019-10-18 09:39
还能这样获取,学到了
作者: 恋爱ing    时间: 2019-10-18 09:41
.........解决了。。然后把问题删了。。。这真的是。。。。。。服了

哎。
作者: 全球VPS大学    时间: 2019-10-18 16:28
恋爱ing 发表于 2019-10-18 09:41
.........解决了。。然后把问题删了。。。这真的是。。。。。。服了

哎。

答案在下面啊,服了!  
作者: chinayang    时间: 2019-10-18 16:29
全球VPS大学 发表于 2019-10-18 16:28
答案在下面啊,服了!

有答案没问题啊
作者: 恋爱ing    时间: 2019-10-18 19:17
chinayang 发表于 2019-10-18 16:29
有答案没问题啊

路人都看得懂我再说啥。




欢迎光临 全球主机交流论坛 (https://loc.888543.xyz/) Powered by Discuz! X3.4