Two pits encountered in recent mobile front-end projects

Source: Internet
Author: User

Despite the need to avoid, but not to mention that the pit is often trampled, do not think that the mobile phone is Webkit the world is simple, do not handle compatibility between browsers,-in fact, the problem of inconsistency is quite large.

Two bugs are involved in the IFRAME--iframe really bad!

The thing is, a page embedded in the IFRAME, because it is necessary to return tokens from the authentication interface as login credentials, read the interface information is not a problem, and then need to use the session to save the login information. Strangely, the session is invalid, as if it were lost! It's okay to leave the IFRAME as a separate page. And not all phones are like this, high-version Android and Apple are like this (desktop and some versions of Android normal). We know that cookies are generally used on a one-to-one session, and it is not possible to use cookies as "pleasant" as the lower version, given the more sophisticated security mechanisms of the IFRAME cookies.

Then simply with party a said we "painstakingly", helpless under, had to use the most stupid method, through the URL parameter passed authentication data. Also several pages, add up also not so painful ...

The second pit is Apple-exclusive, and Safari can't constrain the width of the page within the IFRAME! Android is OK. Simply say that the embedded page will appear distorted on the mobile side, even if you add

<meta name="viewport" content="width=320, initial-scale=1, user-scalable=yes" />
is not valid. If you write a dead width then you will not be compatible with all Apple screens. So I centered the text, but some people do not agree with this does not conform to the beautiful approach, so I use JS read screen width and then write Document.body.style.width. Two lines of code to fix, the key is the idea.

Two pits encountered in recent mobile front-end projects

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.