为什么即使使用不同的输入名称,Firefox也会自动完成? [英] Why Firefox autocomplete even with different input name?

查看:182
本文介绍了为什么即使使用不同的输入名称,Firefox也会自动完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我改变输入元素的名称,编号,标题,类别,Firefox会一直填充密码或电子邮件。如果我正确理解Firefox的源代码,浏览器将首先在窗体中查找密码字段。

如果表单包含超过3个密码字段,自动填充功能将忽略该表单。



在找到1到3个密码字段后,浏览器会查找登录字段。浏览器从第一个密码字段开始向后搜索,并假定登录字段是类型为code的文本的第一个被找到的字段。或者 email url tel number



下一步取决于是否在页面加载或提交表单时检查表单。
如果我们在页面加载过程中检查,并且有一个登录字段和一个密码字段,情况很简单,浏览器可以填写表单。



其他情况下(表单提交或超过1个密码字段)做一些聪明的逻辑,以确定哪个密码字段包含新密码,哪一个旧密码,可能更新存储的密码)。如果您对细节感兴趣,请下载源代码并打开 toolkit / components / passwordmgr / nsLoginManager.js 文件。要检查的函数是 _fillForm _getFormFields _getPasswordFields / p>

只要总结一下,Firefox不需要任何ID,名称或类属性来猜测哪个字段是登录名或密码。它只依赖于表单字段的类型和顺序。


Or How does Firefox determine where the password/username goes?

If I change name, id, title, class of an input element Firefox keeps filling it with password or email.

解决方案

If I understand Firefox's source code correctly, the browser first looks for password fields in forms. If form contains more than 3 password fields, the autofill function ignores that form.

After 1 to 3 password fields are found, the browser looks for login field. The browser does a backward search starting from first password field and assumes that the login field is the first found field of the type text or email or url or tel or number.

Next step depends if we check the forms on page load or when submitting the form. If we check during page load and there is a login field and exactly ONE password field, the case is simple and the browser can fill out the form.

Other cases (form submit or more than 1 password field) do some "smart" logic to determine which password field contains new password and which one the old password, probably to update stored passwords). If you're interested in details, download the source code and open toolkit/components/passwordmgr/nsLoginManager.js file. Functions to check are _fillForm, _getFormFields and _getPasswordFields.

Just to summarize, Firefox doesn't need any ID, name or class attributes to guess which field is login or password. It just relies on types and the order of form fields.

这篇关于为什么即使使用不同的输入名称,Firefox也会自动完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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