HTML/CSS/JS: How to force browser to save password from a non-'password' type input?

笑着哭i 提交于 2019-12-23 13:25:35

问题


The thing is that I have two values which are similar to a username and password, but are actually 2 randomly generated GUID's that users use to login to a website I made - they are not really a username and password, but with the GUIDs I try to replicate this combination.

Usually browsers ask you if you want to save the provided login values when seeing the type='password' attribute for an element. However, a type='password' attribute would make typing a GUID in a field rather difficult, since you can't see what you are typing.

So, how would you force or trick the browser to save a username/password combination without using the type="password" attribute?

Thanks!


回答1:


What if you save a cookie on the client side, maybe with the text encrypted and when the user comes back to the site you first look if he has a cookie saved? Of course, it's a workaround and the cookie won't be there forever, but it's an option.

I'm also thinking you might make a CSS-hidden password input and copy the content to that before submiting the form, but I'm not sure that that tricks the browser.




回答2:


Check out Brad's answer here:

HTML/CSS: How to make "password" input show the password?




回答3:


I would think a cookie would be the easiest solution... At least until you can find something better... +1 for Claudiu's answer



来源:https://stackoverflow.com/questions/4004400/html-css-js-how-to-force-browser-to-save-password-from-a-non-password-type-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!