How to remove the browser's built-in password saving function?

Previously, there was a bug like this when you logged in. When you click on the sign-in browser will prompt you to "save password". Then if the user accidentally clicks on this "save" when they go online in a field such as an Internet cafe, it will be troublesome. After shutting down and leaving, the next person comes in and logs in directly. It is not safe for someone like us to make a wallet to directly enter the funds, andYou can also find the clear text of the password in the cookie in the Firefox browser, so the product has been asking us to remove this prompt from the front end. I have Baidu for a long time, there are various ways, but I have not found one that really solves this prompt. Say nothing, go directly to the code:

Before the code above, tell me my principle: The browser prompted for "save" because it judged that you had type="password" in the form ahead of time, so it won't be prompted to remove this property fundamentally. So the solution is to use two types: text, change to password when you focus, change back to text when you lose focus, and replace it with'<'Replace the password as follows:

<input type="text" onfocus="removePwdDrop.falseOnfocus()" id="falsePwd" placeholder="Logon Password" style="display:none;" />
<input type="text" onfocus="removePwdDrop.pwdOnfocus(this)" onblur="removePwdDrop.pwdOnblur(this)" tabindex="2" onpaste="return false" ondrop="return false" ondragenter="return false;" ondragstart="return false" name="passwdput" id="memberpasswd" class="loginInput" placeholder="Logon Password" autocomplete="new-passwdput" autocomplete="off" />

//Notes:pwd1:Fake password box,pwd2:True password box,To submit
var removePwdDrop = {
        pwdOnfocus: function (obj) { // Change the type to password when the mouse is focused, defaulting to text
            obj.style.display = 'block';
            obj.setAttribute('type', 'password');
        },
        pwdOnblur: function(obj){ // When the mouse loses focus, the previously entered password is assigned topwd1 Use "●"replace
            var pwd1 = document.getElementById("falsePwd")
            var isChrome = window.navigator.userAgent.indexOf("Chrome")
            pwd1.value = ''
            var length = obj.value.length;
            for(var i = 0;i<length;i++){ // Here Google and other browsers show different dots, so make a judgment
                if(isChrome < 0){
                    pwd1.value += '●'
                }else{
                    pwd1.value += '\u2022'
                }
            }
            obj.setAttribute('type', 'text');
            obj.style.display = 'none';
            pwd1.style.display = 'block';
        },
        falseOnfocus: function () { // Here when the mouse is focused onpwd1 On top, shift the focus of the cursor topwd2 Above, this will executepwdOnfocus()Method, hide itself,
            var pwd1 = document.getElementById("falsePwd")
            var pwd2 = document.getElementById("memberpasswd")
            pwd1.style.display ="none";
            pwd2.style.display ="";
            pwd2.focus();
        }
    }

If there is something wrong, please correct it!!!

Keywords: Firefox Google

Added by kabucek on Mon, 13 Apr 2020 19:33:01 +0300