HTML5 本地存储 localStorage SessionStorage StorageListener- 2
%setion
%p= "localStorage"
%aside
%ul
%li
%button.add= "添加数据"
%li
%button.get= "获取数据"
%li
%button.remove= "移除数据"
%li
%button.click= "清除数据"
%li
%button.parse= "解析JSON数据"
%section.localStorage
pie={};
pie.load = function(func){
jQuery(function(){
try{
func();
}catch(e){
console.log("PIE: js加载错误 " + e);
}
});
}
pie.load ->
$userData = {
name:"Sankyu Name",
account:"sankyu",
level:1,
disabled:true
}
localStorage.getItem("userData")
jQuery('.get').on 'click', ->
$localStorage = jQuery('.localStorage')
$localStorage.html(localStorage.getItem("userData"))
jQuery('.add').on 'click', ->
$localStorage = jQuery('.localStorage')
localStorage.setItem("userData",JSON.stringify($userData))
$localStorage.html("增加成功")
jQuery('.remove').on 'click', ->
localStorage.removeItem("userData")
$localStorage = jQuery('.localStorage')
$localStorage.html("删除成功")
jQuery('.click').on 'click', ->
localStorage.clear
$localStorage = jQuery('.localStorage')
$localStorage.html("已清除")
jQuery('.parse').on 'click', ->
$parse = JSON.parse(localStorage.getItem("userData")).name
$localStorage = jQuery('.localStorage')
$localStorage.html($parse)
jQuery(window).on 'load', ->
window.addEventListener("storage",
((e) ->
console.log(e)
$storage = jQuery('p .storage')
$storage.html("删除成功")
),true)
localStorage.clear
localStorage.setItem("userData","storage demo")
localStorage.setItem("userData", "storge event demo")
上一篇: cdr怎么绘制几何体静物素描图?
下一篇: 在CDR如何插入特殊符号字符?
推荐阅读
-
本地存储常用方式 localStorage, sessionStorage,cookie 的区别 和 服务器存储session
-
解析HTML5中的新功能本地存储localStorage
-
HTML5 本地存储 localStorage SessionStorage StorageListener- 2
-
HTML5开发学习(2):本地存储之localStorage 、sessionStorage、globalStorage
-
html5本地存储 localStorage操作使用详解
-
HTML5 LocalStorage 本地存储刷新值还在
-
jQuery访问浏览器本地存储cookie、localStorage和sessionStorage的基本用法
-
HTML5 LocalStorage 本地存储详细概括(多图)
-
利用H5本地存储localStorage、sessionStorage
-
html5的web存储 sessionStorage和 localStorage