兩種用法一樣,
區(qū)別:session關(guān)閉本頁面時(shí),數(shù)據(jù)清空;local一直存在。
取數(shù)據(jù):存儲(chǔ)的是字符串
1、存儲(chǔ)的是數(shù)組時(shí):
// 定義一個(gè)數(shù)組
var exportall = [];
// 獲取本地存儲(chǔ)數(shù)據(jù)
var sStorage = window.sessionStorage;
var exportall = sStorage.getItem("arr").split(",");
if (exportall == null) {
exportall = [];
};
2、 存儲(chǔ)
sStorage.setItem("arr", exportall); // 數(shù)組會(huì)自動(dòng)轉(zhuǎn)化成字符串存儲(chǔ)
3、移除記錄
removeItem
4、清除記錄
clear
其他儲(chǔ)存方式
http://blog.csdn.net/u013063153/article/details/52458348