首页 > Web开发 > 详细

web Storage

时间:2017-05-13 20:38:50      阅读:316      评论:0      收藏:0      [点我收藏+]
localStorage,sessionStorage
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <textarea id="text" cols="80" rows="10"></textarea>
    <input type="button" value="set" id="btn-set">
    <input type="button" value="get" id="btn-get">
</body>
<script>
    var btnSet = document.querySelector(#btn-set);
    var btnGet = document.querySelector(#btn-get);
    var text = document.querySelector(#text)
    btnGet.addEventListener(click,function(){
       /* if(window.localStorage){
            text.value = localStorage[‘key1‘];
        }*/
        if(window.sessionStorage){
            /*alert("支持");*/
            text.value = sessionStorage[key1];
        }
    });
    btnSet.addEventListener(click, function () {
      /*  localStorage[‘key1‘] = text.value;*/
        sessionStorage[key1] = text.value;
    });
</script>
</html>

技术分享

 

web Storage

原文:http://www.cnblogs.com/suxiaoxia/p/6850235.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!