欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js簡單判斷移動端系統(tǒng)的方法

 更新時間:2016年02月25日 09:56:52   作者:小壞  
這篇文章主要介紹了js簡單判斷移動端系統(tǒng)的方法,通過JavaScript的navigator.userAgent相關屬性判斷訪問端的系統(tǒng)類型,非常簡單實用,需要的朋友可以參考下

本文實例講述了js簡單判斷移動端系統(tǒng)的方法。分享給大家供大家參考,具體如下:

<!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數(shù)據(jù)結構與算法技巧總結》、《JavaScript遍歷算法與技巧總結》及《JavaScript數(shù)學運算用法總結

希望本文所述對大家JavaScript程序設計有所幫助。

相關文章

最新評論