首页 > 代码库 > h5新特性
h5新特性
!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
<script type="text/javascript">
// 使用sessitonStrolage进行存储
// 保存
sessionStorage.setItem(‘key1‘, ‘value1‘);
sessionStorage.setItem(‘key2‘, JSON.stringify([1, 2, 3, 4]));
sessionStorage.setItem(‘key3‘, JSON.stringify({ name: "xiaoming" }));
// 取出
var value = http://www.mamicode.com/sessionStorage.getItem(‘key3‘);
console.log(value);
// 删除
// sessionStorage.removeItem(‘key2‘);
// 清除
sessionStorage.clear();
localStorage.setItem(‘key1‘, ‘value1‘);
var v=localStorage.getItem(‘key1‘)
console.log(v)
</script>
</html>
h5新特性