Home > Web Front-end > JS Tutorial > body text

A simple and practical way to prevent the browser from remembering usernames and passwords_javascript techniques

WBOY
Release: 2016-05-16 17:35:47
Original
2221 people have browsed it

How can I prevent the browser from automatically saving form information, such as username and password?
Many browsers now have auto-fill function. I used autocomplete="off" on input, but the username and password are still remembered in some browsers. Is there any more effective and simple method? Ways to prevent browsers from remembering usernames and passwords?

1. Remember passwords for browsers
1). First of all, most browsers judge the password field based on the type="password" of the form field, so in this case you can take " Method to "dynamically set password field":

Copy code The code is as follows:



Explanation: When this document box gets focus, it becomes the password field, like this The browser will not remember the password. Of course, in order to be more complete, you can also add the autocomplete="off" attribute.
2). In the onload event, clear the value of the password box, that is:
Copy the code The code is as follows:



3). The page uses https protocol, because https will not save the form information.
4). Use flash as the login form. In this case, the browser will not record the form information.
5). Another perversion is to change type="password" to type="text". Because type is not password, the password remembering function will not appear, and then set a variable such as: var val =""Or set a hidden field, and finally use onpropertychange to change the password to a line of dots, and assign the value to val, and then change the value of val when submitting Restore it, because the effect is the same as *. The user cannot see it.

2. For the automatic form filling function of some browser plug-ins
This is more troublesome. I think this situation should be that the plug-in remembers the value of the form field name and then fills in the form. This In this case, I think the value of name can be dynamically changed when the page is loaded, and when the form is submitted, the values ​​of the form are combined into the correct corresponding value and then submitted. This is not verified, just my personal opinion. You can try

If the above methods still don’t satisfy you, then there’s nothing I can do.

Suggestion:
Try clearing the cookies under the corresponding domain name. The browser should remember the username and password based on cookies.
(No, some browsers remember the value you submitted after you submit the form)
(Yes, some browsers do not record it in COOKIE. This is a headache. By the way, enter it in INPUT. How to clear the past values? I hope that the entered values ​​will no longer appear like in the bank)
The way the browser remembers the password is to find the input input box with type password, and then the previous input box is used as Remember the username. So the way to solve this problem is to add an input box of type text between the username input and password input and set the css attribute display to none.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template