When I saw a piece of code from someone else, why did the password input box use onfocus="this.type='password'" instead of using type='password' directly? Placeholder setting prompts
怪我咯2017-06-28 09:29:57
I know the answer. It turns out that it is to prevent the browser from remembering the password. In fact, there is an autocomplete='off' attribute. At the beginning, the type attribute of the password box is set to text, and when it gets the focus, it is changed to password. However, in the latest Firefox The method of changing to version 54 is useless, the password will still be remembered, but the password will not be remembered in chrome
女神的闺蜜爱上我2017-06-28 09:29:57
<body>
<input type="text" onfocus="this.type='password'"/>
<input type="text" id="psd"/>
</body> ;
<script>
document.querySelector("#psd").onfocus = function () {
this.type = 'password';
}
</script>
The two have the same effect and <input type="text" onfocus="this.type='password'"/> You can put a breakpoint on the console to indicate that the two effects should be Same