网页存储web storage---购物车(会员登录)

来源:互联网 发布:淘宝支付密码怎么改换 编辑:程序博客网 时间:2024/05/17 03:02

网页存储web storage:实现购物车操作的会员登录部分

<!doctype html><html lang="en"><head>    <meta charset="UTF-8" />    <title>shopping car</title>    <script type="text/javascript">function sendok(){    if(userid.value!="" && userpwd.value!=""){        localStorage.userid=userid.value;        sessionStorage.userpwd=userpwd.value;        return true;    }else{        alert("请输入账号");        return false;    }}function isload(){    if(localStorage.userid){        userid.value=localStorage.userid;    }}    </script></head><body onload="isload();">    <form action="ch05_05.htm" method="post" onsubmit="return sendok();">        <div>            <label for="userName">请输入你的账号</label>            <input type="text" id="userid" name="" id="" value="" autofocus/>        </div>        <div>            <label for="userName">请输入你的密码</label>            <input type="password" id="userpwd" name="" id="" value="" autofocus/>        </div>              <input id="btn_send" type="submit" value="登录"/>    </form></body></html>

说明:
(1)用户关闭网页,信息继续保留,使用localStorage;
用户关闭网页,信息销毁,使用sessionStorage;
(2)因此,用户名使用localStorage,密码使用sessionStorage;

0 0