歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> HTML5使用local storage存儲的數據在本地是以何種形式保存的

HTML5使用local storage存儲的數據在本地是以何種形式保存的

日期:2017/3/1 10:12:35   编辑:Linux編程

HTML5使用local storage存儲的數據是如何保存在本地的?(我使用的是chrome浏覽器,chrom浏覽器是用sqlite來保存本地數據的)

HTML5 的local storage 是通過浏覽器在本地存儲的數據。

基本使用方法如下:

  1. <script type="text/javascript">
  2. localStorage.firstName = "Tom";
  3. alert(localStorage.firstName);
  4. </script>

這樣的話,就將數據保存到本地了,但是本地數據是以什麼形式進行保存的呢,經過跟蹤,發現在Chrome浏覽器中,數據是以sqlite的數據庫文件形式存儲的。

在windows下,是保存在C:\Documents and Settings\User Name\Local Settings\Application Data\Google\Chrome\User Data\Default\Local Storage 路徑(其中User Name是指當前的用戶名)下的;

在Mac下,是保存在/Users/User Name/Library/Application Support/Google/Chrome/Default/Local Storage路徑(其中User Name是指當前的用戶名)路徑下的

雖然後綴名是.localstorege 但是實際上就是sqlite的數據庫文件,可以用sqlite打開,並看到其中的數據。(可以使用firefox的SQLite Manager附加組件打開)

安裝組件步驟和安裝firebug類似,選擇菜單工具-->附件組件,打開附件組件設置頁,搜索"SQLite Manager"關鍵字,安裝"SQLite Manager"插件後重啟firefox,就可以在工具中看到"SQLite Manager"附加組件了,如下圖所示:

下圖是查看剛剛保存的本地數據文件

Copyright © Linux教程網 All Rights Reserved