HTML and CSS Reference
In-Depth Information
var $i {};
$i.init function()
{
if(!Modernizr.sessionstorage)
{
alert('NosessionStorage!');
return
}
document.getElementById('location').textContent
sessionStorage.location;
};
document.addEventListener("DOMContentLoaded", $i.init, false);
}).call();
</script>
</head>
<body>
<div id "topbar">
<div id "title">sessionStorage [2/2]</div>
<div id "leftnav"><a href "${createLink(action:'sessionstorage')
}">back</a> </div>
</div>
<div id "content">
<ul class "pageitem">
<liclass "textbox">
<p>Previously, you selected: <span id "location"></span></p>
</li>
</ul>
</div>
</body>
</html>
Das Beispiel für localStorage ist ähnlich aufgebaut, verzichtet jedoch auf eine zweite
Webseite. Statt eines iWebKit-UI-Toggles, um die Location an- bzw. auszuschalten,
wird die Anzahl der Seitenabrufe für diesen Benutzer hochgezählt. localStorage.
loadCount wird ganz einfach so initialisiert:
if (!localStorage.loadCount)
localStorage.loadCount 0;
Um den Zähler loadCount um 1 zu erhöhen, wird zunächst der unter loadCount
gespeicherte Wert per parseInt() in eine Zahl verwandelt und dann um 1 erhöht. Das
HTML-Element mit der gleichnamigen ID loadCount dient dann als Container zur
Anzeige des Werts.
localStorage.loadCount parseInt(localStorage.loadCount, 10) + 1;
document.getElementById('loadCount').textContent localStorage.loadCount;
Search WWH ::




Custom Search