zoukankan      html  css  js  c++  java
  • localStorage前端存储数据

    <!DOCTYPE html>
    <html>
    <head>
        <title>localStorage演示</title>
    <meta charset="utf-8">
    </head>
    <body>
        <h5>localStorage演示</h5>
    <script>
        
        window.onload = function(){
            // alert(!window.localStorage);
            if(!window.localStorage){
                alert("浏览器支持localstorage");
                return false;
            }else{
                // alert('ok');
                var storage=window.localStorage;
                //写入a字段
                storage["a"]=1;
                //写入b字段
                storage.b=1;
                //写入c字段
                storage.setItem("c",3);
                console.log(typeof storage["a"]);
                console.log(typeof storage["b"]);
                console.log(typeof storage["c"]);
            }
        }
    </script>
    </body>
    </html>

  • 相关阅读:
    velocity .vm
    @Autowired
    springMVC
    索引
    Adivisor
    计算火车运行的时间
    倒三角
    XML简介
    表单提交方式
    js动态生成表格
  • 原文地址:https://www.cnblogs.com/covet/p/10137325.html
Copyright © 2011-2022 走看看