首页 > 编程 > JavaScript > 正文

js简单判断移动端系统的方法

2019-11-20 10:30:57
字体:
来源:转载
供稿:网友

本文实例讲述了js简单判断移动端系统的方法。分享给大家供大家参考,具体如下:

<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" ><meta name="format-detection" content="telephone=no"><title>Document</title></head><body><script>  var isMobile = {    Android : function() {      return navigator.userAgent.match(/Android/i) ? true : false;    },    BlackBerry : function() {      return navigator.userAgent.match(/BlackBerry/i) ? true : false;    },    iOS : function() {      return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;    },    Windows : function() {      return navigator.userAgent.match(/IEMobile/i) ? true : false;    },    any : function() {      return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());    }  };  if (isMobile.iOS()) {    alert("apple");   } else {    alert("Android");  }</script></body></html>

更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《JavaScript查找算法技巧总结》、《JavaScript动画特效与技巧汇总》、《JavaScript错误与调试技巧总结》、《JavaScript数据结构与算法技巧总结》、《JavaScript遍历算法与技巧总结》及《JavaScript数学运算用法总结

希望本文所述对大家JavaScript程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表