JS judge Mobile end and PC side

Source: Internet
Author: User

This article uses the Device.js plug-in to determine the mobile device

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



Example:
if (Device.mobile ()) {window.location.href = "mobile address";        Alert ("Mobile Side");} else {       window.location.href = "PC-side address";        Alert ("PC-side");}

  

More equipment to determine the following table:

Device JavaScript Method
Mobile Device.mobile ()
Tablet Device.tablet ()
Desktop Device.desktop ()
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 ()
Meego Device.meego ()
Television Device.television ()

Device.js will append the appropriate device style to your HTML node after use

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
Meego Meego
Desktop Desktop
Television Television

Mobile Device Direction judgment

Orientation JavaScript Method
Landscape Device.landscape ()
Portrait

Device.portrait ()

JS judge Mobile end and PC side

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.