Skip to Main Content
建構Android應用程式--使用HTML、CSS和JavaScript 第二版
book

建構Android應用程式--使用HTML、CSS和JavaScript 第二版

by Jonathan Stark, Brian Jepson
May 2012
Intermediate to advanced content levelIntermediate to advanced
176 pages
3h 43m
Chinese
GoTop Information, Inc.
Content preview from 建構Android應用程式--使用HTML、CSS和JavaScript 第二版
80
第五章
sessionStorage
儲存的資料只屬於視窗物件。其他視窗
/
標籤頁不知道這些值,當視窗
/
標籤頁關閉
時,資料會被丟棄。對於視窗專屬狀態有其用處,諸如使用中之標籤頁之高亮度,或
者資料表的排序順序。
在下列範例中,你可以把
localStorage
出現之處換成
sessionStorage
,但
是,記住當你關閉視窗或標籤頁時,
sessionStorage
就不見了
數值的設定很簡單,如下所示:
localStorage.setItem('age', 40);
取出已儲存之值也相當簡單:
var age = localStorage.getItem('age');
你也可以刪除特定之關鍵字及其值,諸如:
localStorage.removeItem('age');
或者,你可以刪除所有的關鍵字及其值,諸如:
localStorage.clear();
假設你的關鍵字都是有效的
JavaScript
符號名稱(無空格、除了底線外無其他標點符號等
等),就可以使用此替代語法:
localStorage.age = 40 //
設定
age
之值
var age = localStorage.age; //
取得
age
之值
delete localStorage.age; //
移除
age
localStorage
sessionStorage
關鍵字是分開儲存的。如果兩者都用到相
同的關鍵字,彼此也不會衝突
把使用者設定儲存至
Local Storage ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

大模型应用开发极简入门 : 基于GPT-4和ChatGPT

大模型应用开发极简入门 : 基于GPT-4和ChatGPT

Olivier Caelen, Marie-Alice Blete
HBase管理指南

HBase管理指南

Posts & Telecom Press, Yifeng Jiang
自然语言处理与计算语言学

自然语言处理与计算语言学

Posts & Telecom Press, Bhargav Srinivasa-Desikan

Publisher Resources

ISBN: 9789862764817