首页 文章

停止Google Chrome自动填写输入[复制]

提问于
浏览
30

这个问题在这里已有答案:

我有 input type text 用户 change their email & passwordaccount setting page .

如何停止 Chrome 自动填充输入 .

Chromelog in 页面记住 input data 并自动填写帐户设置页面 .

Chrome 自动填充 input change my email & password in account setting page

14 回答

  • 30

    您是否明确将值设置为空白?例如:

    <input type="text" name="textfield" value="">
    

    这应该会阻止浏览器将数据放在不应该的位置 . 或者,您可以将自动填充属性添加到表单标记:

    <form autocomplete="off" ...></form>
    
  • 2

    我们不再依赖于黑客攻击 . 您可以将自动完成设置为新密码,它将按预期工作 .

    <input type="password" name="pwd" autocomplete="new-password">
    

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete

  • 0

    Solution 1:<form ..> 标签下放置2行代码可以解决问题 .

    <form id="form1" runat="server" >
    <input style="display:none" type="text" name="fakeusernameremembered"/>
    <input style="display:none" type="password" name="fakepasswordremembered"/>
    
    ...
    

    Read more

    Solution 2: 它从元素中删除"name"和"id"属性,并在1ms后将其分配回来 . 把它放在文件准备好了 .

    $('form[autocomplete="off"] input, input[autocomplete="off"]').each(function () {
    
                    var input = this;
                    var name = $(input).attr('name');
                    var id = $(input).attr('id');
    
                    $(input).removeAttr('name');
                    $(input).removeAttr('id');
    
                    setTimeout(function () {
                        $(input).attr('name', name);
                        $(input).attr('id', id);
                    }, 1);
                });
    

    Solution 3: 在Chrome 60.0.3112.101中测试过

    <input type="password" name="pwd" autocomplete="new-password">
    
  • 9

    从版本55.0.2883.87 m开始,此问题仍然存在 . (在Windows 10上)

    像在表单上设置自动完成属性的解决方案

    或者在提交之前添加虚假输入字段并删除name属性不再起作用,因为Chrome会在删除时忽略或立即自动完成它们 .

    使其当前按预期工作的唯一方法是将autocomplete属性设置为“new-password”

    <input type="text" name="text" autocomplete="new-password">
    

    即使是非密码类型的输入 .

  • 1

    最新版本的Chrome(46.0.2490.86)似乎再次改变了行为 . 这次,AutoFill与 autocompletereadonly 或此处建议的其他变通方法无关(以及这些错误报告https://code.google.com/p/chromium/issues/detail?id=468153https://bugs.chromium.org/p/chromium/issues/detail?id=587466

    相反,AutoFill现在查看输入框旁边的标签,并根据该标签生成自动填充(以及ID和名称) . 一个很大的线索是AutoFill如何实际填充多个领域(例如街道,郊区和州) . 它似乎使用几种技术(标签,名称,id)来辨别字段之间的空间关系 .

    因此,解决方法是将垃圾文本插入隐藏范围内的标签中...

    S<span style="display:none">_</span>uburb:
    

    ...还要混淆/删除id和名称 . 这是我唯一阻止郊区自动填充的东西 .

  • 3

    不幸的是 autocomplete="off" 对我不起作用了 . 所以这是我的解决方案:

    首先阅读然后从元素中删除“ name " and " id ”属性 . 然后,在1ms之后,再次使用之前读取的值设置这些属性 . 对我来说它有效:)

    <form autocomplete="off">
    <input type="text" name="username" id="username" />
    <input type="password" name="password" id="password" />
    </form> <pre> $('form[autocomplete="off"] input, input[autocomplete="off"]').each(function(){ var input = this; var name = $(input).attr('name'); var id = $(input).attr('id'); $(input).removeAttr('name'); $(input).removeAttr('id'); setTimeout(function(){ $(input).attr('name', name); $(input).attr('id', id); }, 1); }); </pre>
  • 1

    试图解决这个问题几乎跳出窗口......似乎Google现在忽略了自动完成ON和OFF . 我曾经使用过较旧的修复程序(例如伪造的隐藏密码字段 - 这些字段也不再起作用) . 根据生活标准规范 - 您需要使用自动填充令牌 . 您必须在适当的用例上下文中使用它们 . 希望这是有帮助的 .

    https://html.spec.whatwg.org/multipage/forms.html#autofilling-form-controls:-the-autocomplete-attribute

  • 4

    Chrome会忽略autocomplete =“any”和隐藏字段 . HTML / CSS解决方法是在真正的密码字段之前使用绝对定位的密码字段:

    <input type="text" name="username" required>
    <input style="visibility: hidden; position: absolute; left:-99999px" type="password" name="fakepasswordfieldtoturnoffautocomplete">
    <input type="password" name="password" required>
    

    编辑:

    如其他重复问题中的其他多个答案所述,到目前为止最优雅的工作解决方案是:

    <input type="password" readonly onfocus="this.removeAttribute('readonly');"/>
    
  • 0

    我遇到了类似的问题 . 在所有尝试失败后 . 我尝试了这个设置的黑客

    type = "search"
    

    而不是文字 . 即使它不是一个漂亮的黑客 . 在大多数情况下,它不会导致任何问题 . 类型搜索与现在的文本没有什么不同 .

  • 18

    尝试隐藏密码元素

    <form>
       <input type="text" name="fakeusername" class="fake-autofill-fields"/>
        <input type="password" name="fakepassword" class="fake-autofill-fields"/>
    ...
    ...
    </form>
    
    
    <script>
        $(document).ready(function () {
            $(".fake-autofill-fields").show();
            window.setTimeout(function () {
    
                $(".fake-autofill-fields").hide();
            }, 1);
        });
    </script>
    
  • 1

    为用户名字段输入值''(空格),Chrome不会自动填充用户名或密码 .

    <input type = 'text' value = ' ' name = 'username' />
    

    如果您使用用户输入的值填充用户名,则在没有用户输入值的情况下输入“'代码 .

  • 0

    试试这个:

    <div id="form_container">
        <input type="text" name="username" autocomplete="off">
        <input type="password" name="pwd" autocomplete="off">
        <input tytep="submit" name="login" id="login" value="Log In">
    </div>`
    

    jquery代码:

    jQuery("#login").click(function(){
        jQuery("#form_container").wrap('<form method="post"></form>');
        jQuery("form").submit();
    });
    

    如果您没有将输入字段包装到表单中,则Chrome的自动填充将不会出现 .

    当您单击提交按钮时,只需填写表单周围的字段并在表单上触发 submit() .

  • 0

    这有效:

    <form autocomplete="off" ...></form>
    

    在Chrome 56.0.2924.87(64位)上测试

  • 54

    通过设置autocomplete =“new-password”,它可以正常工作 . 在测试之前,您首先清除浏览数据

相关问题