HTML5   发布时间:2022-04-25  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Html5系列(十一)store.js - 轻松实现本地存储(LocalStorage)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

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)

大佬总结

以上是大佬教程为你收集整理的Html5系列(十一)store.js - 轻松实现本地存储(LocalStorage)全部内容,希望文章能够帮你解决Html5系列(十一)store.js - 轻松实现本地存储(LocalStorage)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。