store.js - 輕松實現本地存儲(LocalStorage)


  store.js 是一個兼容所有瀏覽器的 LocalStorage 包裝器,不需要借助 Cookie 或者 Flash。store.js 會根據瀏覽器自動選擇使用 localStorage、globalStorage 或者 userData 來實現本地存儲功能。

您可能感興趣的相關文章

 

 

store.js 提供非常簡潔的 API 來實現跨瀏覽器的本地存儲功能:

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

 

本文鏈接:store.js - 輕松實現本地存儲(LocalStorage)

編譯來源:夢想天空 ◆ 關注前端開發技術 ◆ 分享網頁設計資源


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM