Html5系列(十一)store.js - 輕鬆實現本機存放區(LocalStorage)__div

來源:互聯網
上載者:User

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)

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.