实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<div id="result"></div>
6
<script>
7
if(typeof(Storage)!=="undefined")
8
  {
9
  localStorage.lastname="Smith";
10
  document.getElementById("result").innerHTML="Last name: " + localStorage.lastname;
11
  }
12
else
13
  {
14
  document.getElementById("result").innerHTML="Sorry, your browser does not support web storage...";
15
  }
16
</script>
17
18
</body>
19
</html>