代码示例:(标识:jsck_win_localstorage_1)
<!DOCTYPE html>
<html>
<body>

<div id="result"></div>

<script>
// 检查浏览器支持
if (typeof(Storage) !== "undefined") {
  // 存储
  localStorage.setItem("lastname", "Smith");
  // 取回
  document.getElementById("result").innerHTML = localStorage.getItem("lastname");
} else {
  document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
}
</script>

</body>
</html>
运行结果: