【问题标题】:Detecting browser autofill before selection在选择之前检测浏览器自动填充
【发布时间】:2015-02-18 01:49:57
【问题描述】:

在用户从下拉列表中选择一个选项之前,我是否可以检测到自动填充?

预期:400010 如所见。

目前我有:

$('input').on('input paste change keyup', function(event) {
    if(event.type=='input'){
      console.log( $(this).val() ); 
    }
});

.. 它在用户做出选择之后起作用,但在上面的屏幕截图中看到之前不会。

【问题讨论】:

  • @DarkHorse 不,试过了,这些解决方案都不起作用。
  • 澄清一下,在选择后检测到更改 is 并且该字段仍处于焦点状态,但是当用户将鼠标悬停在选项上时,我需要在选择期间更改文本.
  • 出于相当明显的安全原因,您无权访问用户存储的自动填充数据
  • 不幸的是,这是不可能的...... :(这是issue的报告,他们说We do send a change event when a user chooses to autofill. I think the "bug" you're observing is that username/pw fields aren't really autofilled until the user interacts with the page (for security/privacy reasons).希望这会有所帮助。

标签: javascript jquery events autocomplete autofill


【解决方案1】:

试试这样:

$(document).ready(
function (event) {
    $('.ddClass').on('mouseenter', 'option', function(e) {
    $("#zipcode").val(this.value);

);
});

//其中.ddClass是下拉选项的类

【讨论】:

  • 这不就是:$('input:not([type=password]), textarea, select').on('hover', function(event) { if(event.type=='hover'){ console.log( "hover: " + $(this).val() ); } });
  • 它不起作用。请观看此截屏视频:dropbox.com/s/bgvb0i0x4u8urpi/2015-01-21_1119.swf?dl=0
  • 我的邮箱被屏蔽了
【解决方案2】:

Read this article,他们深入检测到的自动填充事件。问题是并非所有浏览器都支持自动填充事件,但我认为在用户做出选择之前支持此功能不会有任何愚蠢的做法。想一想:如果他们在做出选择之前支持自动填充事件,那么窃取人们的密码、邮政编码、信用卡等将非常简单。因为您可以发送一个包含自动完成信息的 AJAX 请求。字段,无论用户是否实际选择了它们。

对不起,如果我不能提供更多帮助的话。

【讨论】:

    猜你喜欢
    • 2020-01-08
    • 2012-07-27
    • 1970-01-01
    • 2012-05-23
    • 2015-11-13
    • 2013-04-04
    相关资源
    最近更新 更多