【问题标题】:Password save in Cache/Cookie?密码保存在缓存/Cookie 中?
【发布时间】:2015-10-06 00:37:44
【问题描述】:

有没有办法在缓存中保存输入类型“密码”?

所以每次您访问该页面时,都不需要密码。 但跳到下一步

<input type="password" name="lock_password" />

我尝试使用 html5 LocalStorage 但失败了。

【问题讨论】:

    标签: javascript jquery html passwords storage


    【解决方案1】:

    旧版浏览器不支持 HTML5 Web 存储

    • Chrome:4.0 或更高版本
    • IE:8.0 或更高版本
    • FF:3.5 或更高
    • Opera:11.5 或更高版本
    • Safari:4.0 或更高版本

    可以这样保存您的 PW:

    HTML

    <input id="testPassword" type="password" name="lock_password" />
    

    JAVASCRIPT

    // check if local storage is available
    if(typeof(Storage) !== "undefined") {
        // locale Storage supported
    
        // getting password from input
        var pw = document.getElementById("testPassword").value;
    
        // saving password in local storage
        localStorage.setItem("passwordKey", pw);
    
        // test if password is saved in local storage
        alert(localStorage.getItem("passwordKey"));
    } else {
        // no local storage available
    }
    

    JSFIDDLE

    【讨论】:

      猜你喜欢
      • 2017-04-09
      • 1970-01-01
      • 1970-01-01
      • 2017-07-24
      • 2012-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多