Mobile WAP page Development Little note

Source: Internet
Author: User

Recently accidentally developed a mobile phone WAP page, remember something fresh, hey.


1. To mark the page as a mobile WAP page, you can increase the recognition degree of WAP pages by Baidu and other tools.

Example:<! DOCTYPE HTML PUBLIC "-//wapforum//dtd XHTML Mobile 1.0//en" "Http://www.wapforum.org/DTD/xhtml-mobile10.dtd" >

At the same time, the <title> mark "apple*", but also conducive to search tools search Oh (this one is not recommended, after all, to change the title).

Example: <title>applexxxx mobile Version </title>


2. Set the viewport. Instructions for using meta viewport tags (mobile browsing zoom control)

Width of the Width-viewport
The height of the Height-viewport
Initial-scale-Initial zoom ratio
Minimum-scale-Minimum scale to allow the user to zoom
Maximum-scale-Maximum scale to which the user is allowed to zoom
User-scalable-whether the user can manually scale

Example: <meta name= "viewport" content= "width=640, target-densitydpi=320, User-scalable=no" >


3. In addition, a WAP page read and write local storage JS method, the pros and cons self-defense.

/**
* Get the values in the browser's local cache
* @param name
* @returns
*/
function Getlocalvalue (name) {
if (window.localstorage) {//HTML 5, for mobile phone-side
if (localstorage.getitem (name) = = null) {
Localstorage.setitem (name, 0);
}
Alert ("HTML5 get:" + localstorage.getitem (name));
return Localstorage.getitem (name);
} else {
var Cookiearray = Document.cookie.split (";"); Get the cookie name value of the split
for (var i = 0; i < cookiearray.length; i++) {
var arr = cookiearray[i].split ("="); Separating the name and value
if (arr[0] = = name)
Return unescape (arr[1]); Returns the value of the specified cookie if it is
}
return "0";
}
}


/**
* Set the value in the browser's local store
* @param name,value
* @returns {Boolean}
*/
function Setlocalvalue (name,value) {

if (window.localstorage) {//html 5, for mobile phone side
Ifvalue!=null &&value! = 'undefined‘){
Localstorage.setitem (name,value);
}

}else{
Ifvalue!=null &&value! = ' undefined ') {
Document.cookie =name + "="+value;
}
}

return true;
}

Mobile WAP page Development Little note

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.