HTML and CSS Reference
In-Depth Information
Wenn der Key loadCount nicht vorhanden ist, wird er mit 1 initialisiert. Die Liste zeigt
entsprechend den Wert an. Die Seite wird nun zwei weitere Male geladen, wodurch
loadCount je um 1 erhöht wird und somit 3 ist. Es wurden nun per JavaScript zwei
weitere Key/Value-Paare hinzugefügt, die in der Liste angezeigt werden.
Bild 2.60: Beispiel einer loadCount -Operation.
Hier das vollständige Beispiel zur localStorage -Seite:
<html>
<head>
<title>HTML5</title>
<meta name "layout" content "webkit" />
<style type "text/css" media "screen">
</style>
<script src "${resource(dir:'js',file:'modernizr 1.1.min.js')}"
type "text/javascript"></script>
<script>
(function my() {
var $i {};
$i.init function()
{
if(!Modernizr.localstorage)
{
alert('NolocalStorage!');
return
}
if(!localStorage.loadCount)
localStorage.loadCount 0;
localStorage.loadCount parseInt(localStorage.loadCount, 10) + 1;
document.getElementById('loadCount').textContent
localStorage.loadCount;
Search WWH ::




Custom Search