【问题标题】:Firefox autofill/autocomplete keeps filling new username/password formFirefox 自动填充/自动完成不断填写新的用户名/密码表单
【发布时间】:2019-05-11 12:52:30
【问题描述】:

我正在尝试创建一个表单,管理员用户可以在其中创建一个新用户并为其设置密码,但 Firefox 一直在使用最初登录的用户凭据填写这些表单元素。

这就是我的 html 的样子:

<input id="account-un" class="new-user-name" type="text" placeholder="Please set a password for this account" value="" autocomplete="off">
<input id="account-psw" class="new-user-password" type="password" placeholder="Please set a password for this account" value="" autocomplete="new-password">

我在这两个字段上都尝试过autocomplete="off",但似乎没有任何效果。有什么方法可以阻止 Firefox 或/和任何其他浏览器自动填充这些类型的表单?

我使用的是 Firefox 63.0.3

【问题讨论】:

    标签: html firefox autocomplete


    【解决方案1】:

    我没有检查过,但你可以试试这个旧解决方案:

         if (document.getElementsByTagName) {
    
        var inputElements = document.getElementsByTagName(“input”);
    
        for (i=0; inputElements[i]; i++) {
    
        if (inputElements[i].className && (inputElements[i].className.indexOf(“disableAutoComplete”) != -1)) {
    
        inputElements[i].setAttribute(“autocomplete”,”off”);
    
    }
    
    }
    
    }
    

    来源:https://css-tricks.com/snippets/html/autocomplete-off/#comment-88998

    【讨论】:

      猜你喜欢
      • 2010-11-29
      • 1970-01-01
      • 1970-01-01
      • 2016-05-05
      • 2020-10-29
      • 2022-12-04
      • 2011-08-08
      • 2014-12-07
      • 2018-08-31
      相关资源
      最近更新 更多