首页 > 代码库 > localstorage

localstorage

今天学习了H5的新标签localstorage,属于永久存储,不手动删除怎不会消失;

<body>

  <p id="info"></p>

  <script >

    var info =document.querySelector("#info");

    //处理兼容

    if(typeof(localStorge) != undefined){

      if(localStorage.name){

        info.innerHTML = localStorage.name;

        }else {

        info.innerHTML = "早上好”;

     }else{

      alert("请升级您的浏览器“);

  }

localstorage