localStorage保存帳號密碼

首先是判斷瀏覽器是否支持這一屬性,他是HTML5裏的屬性:瀏覽器

if(window.localStorage){
 alert('支持');
}else{
 alert('不支持');
}spa

 

localStorage.a = 3;//設置a"3"
localStorage["a"] = "sfsf";//設置a"sfsf",覆蓋上面的值
localStorage.setItem("b","isaac");//設置b"isaac"
var a1 = localStorage["a"];//獲取a的值
var a2 = localStorage.a;//獲取a的值
var b = localStorage.getItem("b");//獲取b的值
localStorage.removeItem("c");//清除c的值
rem

 

而後就是進登陸頁面填充get

if (localStorage.key_id && localStorage.username)
{
  $("#login_merchant_id").val(localStorage.key_id);
  $("#login_username").val(localStorage.username);
} ;登錄

 

帳號密碼正確時保存密碼

localStorage.key_id = key_uni;
localStorage.username = username;ant

相關文章
相關標籤/搜索