Chrome ignores autocomplete=“off”

后端 未结 30 1558
礼貌的吻别
礼貌的吻别 2020-11-22 00:42

I\'ve created a web application which uses a tagbox drop down. This works great in all browsers except Chrome browser (Version 21.0.1180.89).

Despite both the

相关标签:
30条回答
  • 2020-11-22 01:14

    It appears that Chrome now ignores autocomplete="off" unless it is on the <form autocomplete="off"> tag.

    0 讨论(0)
  • 2020-11-22 01:14

    Autocomplete="Off" doesn't work anymore.

    Try using just a random string instead of "Off", for example Autocomplete="NoAutocomplete"

    I hope it helps.

    0 讨论(0)
  • 2020-11-22 01:18

    For a reliable workaround, you can add this code to your layout page:

    <div style="display: none;">
     <input type="text" id="PreventChromeAutocomplete" 
      name="PreventChromeAutocomplete" autocomplete="address-level4" />
    </div>
    

    Chrome respects autocomplete=off only when there is at least one other input element in the form with any other autocomplete value.

    This will not work with password fields--those are handled very differently in Chrome. See https://code.google.com/p/chromium/issues/detail?id=468153 for more details.

    UPDATE: Bug closed as "Won't Fix" by Chromium Team March 11, 2016. See last comment in my originally filed bug report, for full explanation. TL;DR: use semantic autocomplete attributes such as autocomplete="new-street-address" to avoid Chrome performing autofill.

    0 讨论(0)
  • 2020-11-22 01:18

    Seen chrome ignore the autocomplete="off", I solve it with a stupid way which is using "fake input" to cheat chrome to fill it up instead of filling the "real" one.

    Example:

    <input type="text" name="username" style="display:none" value="fake input" /> 
    <input type="text" name="username" value="real input"/>
    

    Chrome will fill up the "fake input", and when submit, server will take the "real input" value.

    0 讨论(0)
  • 2020-11-22 01:19

    I am posting this answer to bring an updated solution to this problem. I am currently using Chrome 49 and no given answer work for this one. I am also looking for a solution working with other browsers and previous versions.

    Put this code on the beginning of your form

    <div style="display: none;">
        <input type="text" autocomplete="new-password">
        <input type="password" autocomplete="new-password">
    </div>
    

    Then, for your real password field, use

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

    Comment this answer if this is no longer working or if you get an issue with another browser or version.

    Approved on:

    • Chrome : 49
    • Firefox : 44, 45
    • Edge : 25
    • Internet Explorer : 11
    0 讨论(0)
  • 2020-11-22 01:19

    i found this solution to be the most appropriate:

    function clearChromeAutocomplete()
    {
    // not possible, let's try: 
    if (navigator.userAgent.toLowerCase().indexOf('chrome') >= 0) 
    {
    document.getElementById('adminForm').setAttribute('autocomplete', 'off'); 
    setTimeout(function () {
            document.getElementById('adminForm').setAttribute('autocomplete', 'on'); 
    }, 1500);
    }
    }
    

    It must be loaded after dom ready, or after the form renders.

    0 讨论(0)
提交回复
热议问题