html5本地存储webstorage
2016-05-13 16:05
375 查看
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<div>webstorage存储技术</div>
<title></title>
<script src="js/jquery-1.10.2.js"></script>
<script type="text/javascript">
function MyClick() {
var userName = $("#txtUserName").val();
var password = $("#txtPwd").val();
sessionStorage.setItem("k_userName", userName);
sessionStorage.setItem("k_password", password);
//localStorage.setItem("k_userName", userName);
//localStorage.setItem("k_password", password);
alert("存储成功");
}
function MyClick1() {
alert(sessionStorage.getItem("k_userName"));
}
function PostCon() {
var sCon = $("#trCon").val();
$("#dCon").append("<div>" + sCon + "</div>");
localStorage.setItem("k_Con", $("#dCon").html());
}
$(function () {
if (localStorage.getItem("k_Con") != null) {
"k_Con", $("#dCon").html(localStorage.getItem("k_Con"));
}
})
function Clear() {
$("#dCon").html("");
localStorage.clear();
}
</script>
</head>
<body>
<div><input type="text" id="txtUserName" /><input type="button" value="确定" onclick="MyClick()"/></div>
<div><input type="password" id="txtPwd" /><input type="button" value="确定1" onclick="MyClick1()"/></div>
<!--<div><input type="text" id="username" /><input type="button" value="确定" /></div>-->
<div><textarea id="trCon" cols="30" rows="8"></textarea></div>
<div><input type="button" value="Ok" onclick="PostCon()" /><input type="button" value="cancel" onclick="Clear()"/></div>
<div id="dCon"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<div>webstorage存储技术</div>
<title></title>
<script src="js/jquery-1.10.2.js"></script>
<script type="text/javascript">
function MyClick() {
var userName = $("#txtUserName").val();
var password = $("#txtPwd").val();
sessionStorage.setItem("k_userName", userName);
sessionStorage.setItem("k_password", password);
//localStorage.setItem("k_userName", userName);
//localStorage.setItem("k_password", password);
alert("存储成功");
}
function MyClick1() {
alert(sessionStorage.getItem("k_userName"));
}
function PostCon() {
var sCon = $("#trCon").val();
$("#dCon").append("<div>" + sCon + "</div>");
localStorage.setItem("k_Con", $("#dCon").html());
}
$(function () {
if (localStorage.getItem("k_Con") != null) {
"k_Con", $("#dCon").html(localStorage.getItem("k_Con"));
}
})
function Clear() {
$("#dCon").html("");
localStorage.clear();
}
</script>
</head>
<body>
<div><input type="text" id="txtUserName" /><input type="button" value="确定" onclick="MyClick()"/></div>
<div><input type="password" id="txtPwd" /><input type="button" value="确定1" onclick="MyClick1()"/></div>
<!--<div><input type="text" id="username" /><input type="button" value="确定" /></div>-->
<div><textarea id="trCon" cols="30" rows="8"></textarea></div>
<div><input type="button" value="Ok" onclick="PostCon()" /><input type="button" value="cancel" onclick="Clear()"/></div>
<div id="dCon"></div>
</body>
</html>
相关文章推荐
- HTML5之历史管理
- HTML5基础
- 【HTML5】Canvas绘制简单图片教程
- HTML5拖放
- HTML5中的验证功能
- HTML5 LocalStorage 本地存储
- 好好和h5沟通!几种常见的hybrid通信方式
- 从零学习前端开发之 ― HTML5基础和HTML语义化(2) 小月博客
- HTML5 canvas 捕鱼达人游戏
- [HTML5] Canvas绘制简单图片
- HTML5实现页面切换激活的PageVisibility API使用初探
- 使用pano2vr生成html5全景页面
- Web开发者不容错过的10个HTML5工具
- 20款最受欢迎的HTML5游戏引擎收集
- H5 页面适配所有 iPhone 和安卓机型的六个技巧
- HTML5元素、属性和格式化
- HTML5 编辑 API 之 Range 对象(一)
- html5本地存储-遍历以及清空数据
- html5web存储
- html5web通信-跨文档消息传输