Chrome自动填充/自动填充没有密码的值 [英] Chrome Autofill/Autocomplete no value for password

查看:121
本文介绍了Chrome自动填充/自动填充没有密码的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您为某个网站保存了用户名和密码时,Chrome会自动填充该用户名和密码,但是如果您尝试获取密码输入字段的值,它将为空字符串,即使有值。



如果你点击页面上某处, input type =password的值被填充。

这是结构结构的Fiddle 用户名/密码的HTML和 console.log 命令。它在这里是看不到的,但它可以在每个登录表单的页面上重现,并且在页面加载时自动填充用户名和密码。如果您在点击该网站的任何其他位置之前检查该字段的值,它将为空字符串。



在Firefox或Internet Explorer中,情况并非如此,它会填充 input 元素的值与密码。



我使用Windows 7 Ultimate 64位操作系统和Google Chrome版本是48.0.2564.97米



这是正常的行为,bug还是?
$ b 更新:



如果您点击F5重新加载页面并检查密码字段,密码的值将会在那里。如果您点击Chrome左上角的重新加载按钮,密码字段的值将为空字符串。

成为Chrome中的一个bug。当Chrome在初始页面加载时自动填充密码(但不是刷新)时,该值将显示在屏幕上的表单字段中,但在Javascript中查询 passwordField.value 返回一个空字符串。如果你依靠在Javascript中看到这个值,这会阻止你这样做。一旦用户在页面上执行了任何其他操作,例如点击页面上的任何位置,该值突然变得对Javascript可见。



实际上我并不是100%肯定的如果这是一个错误,或者有这样做的安全原因,例如通过欺骗浏览器填充它来防止隐藏的框架窃取您的密码。



我们使用的解决方法是检测Chrome对已自动填充的字段所做的背景颜色更改。 Chrome将自动填充字段的背景颜色设置为黄色,并且这种更改始终对Javascript可见,即使值不是。在Javascript中检测到这一点,可以让我们知道该字段是用值自动填充的,即使我们在Javascript中看到该值为空白。在我们的例子中,我们有一个登录表单,其中提交按钮没有启用,直到您在密码字段中填写了某些内容,并且检测到值或自动填充背景颜色足以确定某个事物在该字段中。然后,我们可以启用提交按钮,然后点击按钮(或按下回车键)立即使得Javascript的密码字段值可见,因为与页面交互可以修复问题,所以我们可以从那里正常进行。


When you have saved username and password for some site Chrome will autofill that username and password, but if you try to get the value for the password input field it is empty String even though there is value there ******.

If you click somewhere on the page no mater where the value of the input type="password" will be filled.

This is Fiddle user/pass of the structure of the html and the console.log command. It cannot be seen here but it can be reproduced on every page that has login form and the username and password are autofilled on the load of the page. If you inspect the value of the field before clicking anywhere else on the site it will be empty String.

This is not the case in Firefox or Internet Explorer it will fill the value of the input element with the password.

I am using Windows 7 Ultimate 64-bit OS and Google Chrome version is 48.0.2564.97 m

Is this normal behavior, bug or?

UPDATE:

If you click on F5 to reload the page and inspect the password field the value for password will be there. If you click the reload button in Chrome in top left corner the value for the password field will be empty string.

解决方案

This seems to be a bug in Chrome. When Chrome auto-fills a password on an initial page load (but not a refresh), the value appears in the form field on-screen, but querying passwordField.value in Javascript returns an empty string. If you depend on seeing that value in Javascript, this prevents you from doing so. Once the user does any other action on the page, such as clicking anywhere on the page, the value suddenly becomes visible to Javascript.

I'm not actually 100% sure if this is a bug, or if there is a security reason for doing this such as preventing a hidden frame from stealing your password by tricking the browser into filling it in.

A workaround that we have used is to detect the background color change that Chrome makes to fields that it has auto-filled. Chrome colors the background of auto-filled fields yellow, and this change is always visible to Javascript even when the value is not. Detecting this in Javascript lets us know that the field was auto-filled with a value, even though we see the value as blank in Javascript. In our case, we have a login form where the submit button is not enabled until you fill in something in the password field, and detecting either a value or the auto-fill background-color is good enough to determine that something is in the field. We can then enable the submit button, and clicking the button (or pressing enter) instantly makes the password field value visible to Javascript because interacting with the page fixes the problem, so we can proceed normally from there.

这篇关于Chrome自动填充/自动填充没有密码的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆