Device.js——检测设备平台、操作系统的Javascript 库
2015-03-06 23:30
459 查看
http://segmentfault.com/a/1190000000373735
Device.js 是一个可以让你检测设备的平台,操作系统和方向 JavaScript 库,它会自动在
Device.js 通过操作系统(比如 iOS,安卓,黑莓,Windows,Firefox OX),方向(横屏或者竖屏),类型(平板或者移动设备),如下面在 iPhone 上的浏览的时候在
Android: Phones & Tablets
Blackberry: Phones & Tablets
Windows: Phones & Tablets
Firefox OS: Phones & Tablets
项目主页:Device.js
https://github.com/matthewhudson/device.js
Device.js 是一个可以让你检测设备的平台,操作系统和方向 JavaScript 库,它会自动在
<html>标签添加一些设备平台,操作系统,方向相关的 CSS class,这样就能让你针对不同设备撰写不同的 CSS,并且还提供一些 Javascript 函数来判断设备。
Device.js 通过操作系统(比如 iOS,安卓,黑莓,Windows,Firefox OX),方向(横屏或者竖屏),类型(平板或者移动设备),如下面在 iPhone 上的浏览的时候在
<html>添加的 CSS Class:
支持的设备
iOS: iPhone, iPod, iPadAndroid: Phones & Tablets
Blackberry: Phones & Tablets
Windows: Phones & Tablets
Firefox OS: Phones & Tablets
如何使用
Device.js 使用非常简单,只需要在页面的 head 载入相关的 JS 库即可:<script src="device.js"></script>
生成的 CSS Class:
Device | CSS Classes |
---|---|
iPad | ios ipad tablet |
iPhone | ios iphone mobile |
iPod | ios ipod mobile |
Android Phone | android mobile |
Android Tablet | android tablet |
BlackBerry Phone | blackberry mobile |
BlackBerry Tablet | blackberry tablet |
Windows Phone | windows mobile |
Windows Tablet | windows tablet |
Firefox OS Phone | fxos mobile |
Firefox OS Tablet | fxos tablet |
Desktop | desktop |
Orientation | CSS Classes |
---|---|
Landscape | landscape |
Portrait | portrait |
相关的 Javascript 函数
Device | JavaScript Method |
---|---|
Mobile | device.mobile() |
Tablet | device.tablet() |
iOS | device.ios() |
iPad | device.ipad() |
iPhone | device.iphone() |
iPod | device.ipod() |
Android | device.android() |
Android Phone | device.androidPhone() |
Android Tablet | device.androidTablet() |
BlackBerry | device.blackberry() |
BlackBerry Phone | device.blackberryPhone() |
BlackBerry Tablet | device.blackberryTablet() |
Windows | device.windows() |
Windows Phone | device.windowsPhone() |
Windows Tablet | device.windowsTablet() |
Firefox OS | device.fxos() |
Firefox OS Phone | device.fxosPhone() |
Firefox OS Tablet | device.fxosTablet() |
Orientation | JavaScript Method |
---|---|
Landscape | device.landscape() |
Portrait | device.portrait() |
https://github.com/matthewhudson/device.js
相关文章推荐
- 检测设备平台,操作系统,方向 Javascript 库:Device.js
- JS----Device.js 检测设备平台,操作系统的javascript
- JavaScript学习笔记之检测客户端类型是(引擎、浏览器、平台、操作系统、移动设备)
- userAgent,JS用户代理检测——判断浏览器内核、浏览器、浏览器平台、windows操作系统版本、移动设备、游戏系统
- Device.js – 快速检测平台、操作系统和方向信息
- JS笔记:检测客户端(引擎、浏览器、平台、操作系统、移动设备)
- userAgent,JS用户代理检测——判断浏览器内核、浏览器、浏览器平台、windows操作系统版本、移动设备、游戏系统
- JavaScript学习笔记之检测客户端类型是(引擎、浏览器、平台、操作系统、移动设备)
- JavaScript高级程序设计阅读笔记(十六) javascript检测浏览器和操作系统-detect.js
- Device.js:物联网JavaScript开发平台
- JavaScript高级程序设计阅读笔记(十六) javascript检测浏览器和操作系统-detect.js
- 基于javascript代码检测访问网页的浏览器呈现引擎、平台、Windows操作系统、移动设备和游戏系统
- 使用device.js检测设备并实现不同设备展示不同网页
- 基于javascript代码检测访问网页的浏览器呈现引擎、平台、Windows操作系统、移动设备和游戏系统
- Javascript识别各种浏览器、渲染引擎、系统平台(操作系统|移动设备|游戏系统)
- userAgent,JS这么屌的用户代理,你造吗?——判断浏览器内核、浏览器、浏览器平台、windows操作系统版本、移动设备、游戏系统
- javascript检测浏览器和操作系统-detect.js
- javascript 检测浏览器类型、操作系统平台的代码
- JS笔记:检测客户端(引擎、浏览器、平台、操作系统)
- 《JavaScript高级程序设计》阅读笔记(十六):javascript检测浏览器和操作系统-detect.js