Commonly used knowledge points on the mobile side

Source: Internet
Author: User

On the mobile side of the development is not very understanding, just do some mobile phone projects, small part of today to organize some of the common mobile development knowledge points, interested friends can also understand, of course, if there is a supplement, you can also send an email to small series Oh ~ ~ ~

1, viewport: so-called viewport, that is, remove all toolbars, status bar, scroll bar and so on to view the area of the Web page, suppose there is now a newspaper in front of you, but this newspaper was pressed by a book, so you can only see part of the newspaper, The visible area of this part refers to viewport;

1 <meta name="viewport"content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no"/>


width = device-width: Sets the width to the device display width;
Initial-scale: Initial zoom ratio (range from 0 to 10);
Maximum-scale: Allows the user to zoom to the maximum scale;
Minimum-scale: Allows the user to zoom to the minimum scale;
USER-SCALABL: Whether the user can zoom manually;

2, in the HTML code, we generally control through <meta>
Coding (This should not be unfamiliar to everyone):

1 <meta charset="utf-8"/>


Block Dial-up links under iphone:

1 <meta name="format-detection"content="telephone=no">


Hide the safari navigation bar and toolbars and display the page in full screen:

1 <meta name=”apple-mobile-web-app-capable” content=”yes” />



3. If you want to prevent the device from automatically resizing when the screen is rotated:

1 -webkit-text-size-adjust:none;

4, <a href= "sms:10010" class= "message" ></a>//Phone text transfer
<a href= "tel:10010" class= "call" ></a>//Pick up phone

5, detection device rotation direction
The iphone can browse the Web on a horizontal screen, and sometimes you'll want to know the handheld state of the user's device to enhance usability and functionality. The following JavaScript can determine which direction the device rotates and replace the CSS:

12345678910111213141516 window.onload = function initialLoad() {updateOrientation();}    function updateOrientation(){     var contentType = "show_";     switch(window.orientation){         case0: contentType += "normal";                   break;           case -90: contentType += "right";                   break;         case90:  contentType += "left";                   break;         case 180: contentType += "flipped";                   break;     }     document.getElementById("page_wrapper").setAttribute("class", contentType);     }

6. Hide the toolbar by default
The iphone's browser toolbar will appear at the top of the page and then be hidden after scrolling the page. This makes it a waste of space when the Web page is loaded, especially when the horizontal screen is in place. We can let it scroll up automatically, the code is as follows:

123 window.addeventlistener ( ' load ' , function () {      settimeout (scrollto,0,0,1); false

7, Touch event
When a user's finger is placed on the screen, some related events are triggered when the screen is slid or removed from the screen, which is called a touch event, with the following:
touchstart : Triggers when the finger touches the screen, Even if you already have a finger on the screen, it triggers
Touchmove: A continuous trigger when the finger slides on the screen
Touchend: Triggers
touchcance when the finger moves away from the screen: when the system stop tracking trigger is triggered, The exact trigger time for such an event is not explicitly stated in the document

the above events will either bubble or be canceled, and each touch event's event object provides properties that are common in mouse events:
Bubbles,cancelable,view, Clientx,clienty,screenx,screeny,detail,altkey,ctrlkey,shiftkey,metakey

In addition to the common DOM properties, the touch time includes the following 3 for tracking touch properties:
touches: An array of touch objects that represent the touch operations that are currently tracked
Targettouches: An array of touch objects that are specific to the event target
Changetouches: An array of touch objects that represent what has changed since the last touch

Each Touch object contains the following properties:
ClientX: Touch the X coordinate of the target in the visual area
ClientY: Touch the Y coordinate of the target in the visual area
PageX:   Touch the x-coordinate of the target in the page
Pagey:  Touch the y-coordinate of the target in the page
ScreenX: Touch the x-coordinate of the target in the screen
ScreenY: Touch Target in the y-coordinate of the screen
target: Touch DOM node target identifier: Identity touch unique ID

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.