store.js - 轻松实现本地存储(LocalStorage)

store.js是一个兼容多种浏览器的LocalStorage封装库,无需依赖Cookie或Flash。它可根据浏览器类型自动选择使用localStorage、globalStorage或userData来实现本地存储功能,并提供简洁的API进行操作。

store.js 是一个兼容所有浏览器的 LocalStorage 包装器,不需要借助 Cookie 或者 Flash。store.js 会根据浏览器自动选择使用 localStorage、globalStorage 或者 userData 来实现本地存储功能。


 

store.js 提供非常简洁的 API 来实现跨浏览器的本地存储功能:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
store.set( 'username' , 'marcus' )
store.get( 'username' )
store.remove( 'username' )
 
store.clear()
 
store.set( 'user' , { name: 'marcus' , likes: 'javascript'  })
 
var  user = store.get( 'user' )
alert(user.name + ' likes '  + user.likes)
 
// Get all stored values
store.getAll().user.name == 'marcus'
 
// Loop over all stored values
store.forEach( function (key, val) {
     console.log(key, '==' , val)
})

支持的浏览器:

  • Tested in iOS 4
  • Tested in iOS 5
  • Tested in iOS 6
  • Tested in Firefox 3.5
  • Tested in Firefox 3.6
  • Tested in Firefox 4.0+
  • Support dropped for Firefox < 3.5 (see notes below)
  • Tested in Chrome 5
  • Tested in Chrome 6
  • Tested in Chrome 7
  • Tested in Chrome 8
  • Tested in Chrome 10
  • Tested in Chrome 11+
  • Tested in Safari 4
  • Tested in Safari 5
  • Tested in IE6
  • Tested in IE7
  • Tested in IE8
  • Tested in IE9
  • Tested in IE10
  • Tested in Opera 10
  • Tested in Opera 11
  • Tested in Opera 12
  • Tested in Node.js v0.10.4 (with https://github.com/coolaj86/node-localStorage 1.0.2)

 

立即下载      GitHub

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值