码迷,mamicode.com
首页 > Web开发 > 详细

web Storage

时间:2017-05-13 21:05:48      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:cal   支持   eve   ges   .com   htm   分享   nbsp   val   

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

标签:cal   支持   eve   ges   .com   htm   分享   nbsp   val   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!