Simple sniffing of Android and iOS, and capturing ideas for the screen

Source: Internet
Author: User

Generally sniff the Android and iOS systems via navigator.useragent:

if (/android/i.test (navigator.useragent)) {

Android

}

if (/iphone/ipad/mac/i.test (navigator.useragent)) {

Ios

}

Differences between Android and iOS in the sense of the screen:

ANDROID:90 degree-90 degrees is vertical screen, 0 degrees 180 degrees is horizontal screen.

ios:0 degree 180 degrees is vertical screen, 90 degrees-90 degrees for horizontal screen.

Mobile browser generally support window.orientation This parameter, through this parameter can determine whether the phone is in a horizontal screen or vertical screen state. The corresponding procedure is executed according to the actual demand.

By adding a listener event Onorientationchange ("Onorientationchange" in Window?) "Orientationchange": "Resize"), you can make a flexible response.

Simple sniffing of Android and iOS, and capturing ideas for the screen

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.