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