device.js--detection device platform, operating system JavaScript library

Source: Internet
Author: User

http://segmentfault.com/a/1190000000373735

Device.js is a platform, operating system and direction JavaScript library that allows you to detect devices, and it automatically adds some device platforms, operating systems, and orientation-related CSS classes to your tags, so you can write different CSS for different devices. Some Javascript functions are also provided to determine the device.

Device.js via OS (such as IOS, Android, BlackBerry, Windows,firefox OX), direction (horizontal screen or vertical screen), type (tablet or mobile device), such as the following in the CSS class added on IPhone browsing:

Supported devices
    • Ios:iphone, IPod, IPad
    • Android:phones & Tablets
    • Blackberry:phones & Tablets
    • Windows:phones & Tablets
    • Firefox Os:phones & Tablets
How to use

Device.js is very simple to use, just load the relevant JS library in the head of the page:

<script src="device.js"></script>
Generated CSS Class: Td>ios ipad tablet
Device CSS Classes
iPad
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
Related Javascript functions
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 ()

Project home: Device.js

Https://github.com/matthewhudson/device.js

device.js--detection device platform, operating system JavaScript library

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.