zoukankan      html  css  js  c++  java
  • jmobile学习之路 ----设备检测

    用一个库,device.js。这是一种最简单的方法。device.js库,不依赖jQuery框架。

     <!doctype html>

    <html lang="en">

    <head>

     <meta charset="UTF-8">

    <title>Document</title>

     <script type="text/javascript" src="device.min.js"></script>  → 首先引入device.js库。

    </head>

     <body>

     <h1 id="biaoti"></h1>

     <script type="text/javascript">

      var myh1 = document.getElementById("biaoti");

      if(device.mobile()){

      myh1.innerHTML = "哈哈,我的设备是手机~";

      }else if(device.ipad()){

      myh1.innerHTML = "我是土豪,我有ipad";

      }else{

      myh1.innerHTML = "我就是一个台式机";

      }

      </script>

     </body>

     </html>

        

    device.portrait() → 检测设备是否是竖直的;

    device.landscape()  → 检测设备是否是水平的;

    device.mobile()   → 检测设备是否是手机;

    device.ipad()  → 检测设备是否是ipad

    device.iphone()  → 检测设备是否是苹果手机;

    device.android()  → 检测设备是否是安卓手机;

    device.tablet()  → 检测设备是否是大屏幕手机(7寸以上);

  • 相关阅读:
    Node.js Net 模块+DNS 模块
    php程序报500错误
    Node.js 工具模块-OS模块+path模块
    Node.js GET/POST请求
    Canvas动画+canvas离屏技术
    Python OS 模块
    Python random 模块
    Python time 模块
    Python 迭代器
    Python 生成器
  • 原文地址:https://www.cnblogs.com/webzwf/p/5908380.html
Copyright © 2011-2022 走看看