简体   繁体   English

HTML / CSS / JS:如何强制浏览器从非'密码'类型输入中保存密码?

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

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. 问题是我有两个类似于用户名和密码的值,但实际上是2个随机生成的GUID,用户用来登录我所做的网站 - 它们实际上不是用户名和密码,但我使用的是GUID复制这个组合。

Usually browsers ask you if you want to save the provided login values when seeing the type='password' attribute for an element. 通常,浏览器会在您查看元素的type ='password'属性时询问您是否要保存提供的登录值。 However, a type='password' attribute would make typing a GUID in a field rather difficult, since you can't see what you are typing. 但是,type ='password'属性会使字段中的GUID变得相当困难,因为您无法看到正在键入的内容。

So, how would you force or trick the browser to save a username/password combination without using the type="password" attribute? 那么,如何在不使用type =“password”属性的情况下强制或欺骗浏览器保存用户名/密码组合?

Thanks! 谢谢!

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? 如果您在客户端保存cookie,可能加密文本,当用户回到网站时,如果他保存了cookie,您会先查看该怎么办? Of course, it's a workaround and the cookie won't be there forever, but it's an option. 当然,这是一种解决方法,cookie不会永远存在,但它是一种选择。

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. 我也在想你可能会提交一个CSS隐藏的密码输入并在提交表单之前将内容复制到该内容,但我不确定这会欺骗浏览器。

我认为一个cookie是最简单的解决方案......至少在你能找到更好的东西之前......对于Claudiu的回答+1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM