2019, Chrome 76, approach to autocomplete off

后端 未结 9 2211
忘掉有多难
忘掉有多难 2020-12-29 04:43

There are are few posts out there about this. You spend hours going through each answer, testing, reading comments, to find that there is no solution. What have you done in

9条回答
  •  星月不相逢
    2020-12-29 05:11

    try this, I used this little trick and it worked until now (September 2020). i hope this works for a lot of people

    --HTML--
    
        
    --Javascript--
    let elements = document.querySelectorAll('[autocomplete="off"]');
    elements.forEach(element => {
        element.setAttribute("readonly", "readonly");
        element.style.backgroundColor = "inherit";
        setTimeout(() => {
            element.removeAttribute("readonly");
        }, 500);
    })
    

提交回复
热议问题