5 ms·
Yep. Set data: window.localStorage.setItem(key, value); Get all data. // (Given that you have the "key" be numeric) /** *
by adamdecaf 16y ago
Yep.
Set data:
window.localStorage.setItem(key, value);
Get all data.
// (Given that you have the "key" be numeric)
/**
* var setData = ['trackingID', 'trackingURL', 'trackingTS'];
* for ( var i = 0; i < setData.length; i++) {
* window.localStorage.setItem(i, setData[i]);
* }
*/
var n = 0, items = [], count = window.localStorage.length;
while (n < count) {
items[n++] = window.localStorage.getItem(window.localStorage.key(n));
}
/* return items; */
-----
Or, you can just set the items with trivial keys (id, timestamp, url) and get the values with window.localStorage.getItem([id, timestamp...]).