HTML/CSS/JS: How to force browser to save password

2019-06-24 01:47发布

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!

3条回答
戒情不戒烟
2楼-- · 2019-06-24 01:56
别忘想泡老子
3楼-- · 2019-06-24 02:19

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.

查看更多
趁早两清
4楼-- · 2019-06-24 02:19

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

查看更多
登录 后发表回答