function clickLogin(){
          var userName = $("#user").val().trim();
          // console.log(userName);
          // $.cookie("userNmae",userName,{expires: 300});
          save_html5_storage("userNmae",userName);
}

// 检测是否支持本地存储
      function supports_html5_storage() {
          try {
              return 'localStorage' in window && window['localStorage'] !== null;
          } catch (e) {
              return false;
          }
      }

      //本地存储保存信息代码
      function save_html5_storage(key,value) {
          if(supports_html5_storage()){
              localStorage[key] = value;
          }
      }
      //读取本地存储信息代码
      function read_html5_storage(key) {
          if(supports_html5_storage()){
              return localStorage[key];
          }
      }


      window.onload = function(){       
        
        $("#user").val(read_html5_storage("userNmae"));
      }

 

posted on 2014-10-27 16:18  凌度  阅读(464)  评论(0编辑  收藏  举报