HTML and CSS Reference
In-Depth Information
// http://www.w3.org/TR/REC-xml/#NT-Name
// simplified to assume the starting character is valid
cleanKey = function ( key ){
return key . replace ( /[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\
u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g , "-" );
};
div . load ( attrKey );
localStorage [ "length" ] =
div . XMLDocument . documentElement . attributes . length ;
}
}
})();
Frameworks
A few JavaScript frameworks address Web Storage needs on mobile devices. When
evaluating Web Storage frameworks, look for a nice consistent storage API that works
across all devices. Of course, this is what the spec itself does through a simple JavaScript
API, but until all devices support this specification, you need a helper framework.
LawnChair
LawnChair ( http://westcoastlogic.com/lawnchair ) is designed with mobile in mind. Sup‐
porting all major mobile browsers, it's adaptive to the mobile and desktop environments
described in this topic and gives you a consistent API for accessing some form of lo
calStorage . LawnChair allows you to store and query data on browsers without wor‐
rying about the underlying API. It's also agnostic to any server-side implementations,
enabling you to get started quickly with a simple, lightweight framework.
The page setup is:
<!DOCTYPE html>
<html>
<head>
<title> my app </theitle>
</head>
<body>
<script src= "lawnchair.js" ></script>
</body>
</html>
To persist data, use:
Lawnchair ( function (){
this . save ({ msg : 'hooray!' })
})
Search WWH ::




Custom Search