<!DOCTYPE html >
<html>
<head>
<meta charset="utf-8" />
<title>使用localStorage</title>
<script language="JavaScript">
var str=JSON.stringify(data);
function savest()
{
var data=new Object;
data.user=document.getElementById('user').value;
data.password=document.getElementById('password').value;
var str=JSON.stringify(data);
localStorage.setItem(data.user,str);
alert("登陆成功");
}
var data=JSON.parse(str);
function getsave(id)
{
var find=document.getElementById('user').value;
var str=localStorage.getItem(find);
var data=JSON.parse(str);
var show=document.getElementById('password');
show.innerHTML=data.password;
}
</script>
</head>
<body onload="getsave()">
<form>
<ul>
<li>用户名
<input id="user" type="text">
</li>
<li>密码
<input id="password" type="password">
</li>
<li >
<input name="btnLogin" value="登陆" type="button" onclick="savest()" >
<input name="rstLogin" type = "reset" value="取消">
</li>
</ul>
</form>
</body>
</html>
摇曳的蔷薇
慕田峪4524236