FireFox 捕获自动完成输入更改事件 [英] FireFox capture autocomplete input change event

查看:25
本文介绍了FireFox 捕获自动完成输入更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试订阅 ajax 自动完成表单的输入标签上的更改事件.当用户点击来自 FireFox 的自动完成建议时,不会触发这些更改事件.

I'm trying to subscribe to change events on an input tag for an ajax auto complete form. These change events are not firing when the user clicks an autocomplete suggestion from FireFox.

我看到了针对 IE 的修复,但没有看到针对 FireFox 的修复.您可以在此处

I've seen fixes for IE, but not FireFox. You can view this behavior here

重新创建的步骤:在其中一个框中键入任何输入,然后单击提交.

Steps to recreate: type any input in one of the boxes and click submit.

在同一个框中再次开始输入值.

Start typing the value again in the same box.

您应该会看到自动完成建议框出现在输入框下方.请注意,点击建议不会触发更改事件(它也不会触发点击事件)

You should see the autocomplete suggestion box appear below the input box. Notice that clicking the suggestion does not fire the change event (it also doesn't fire the click event)

目前我唯一的选择是禁用此字段的自动完成功能,但我不想这样做.

Currently my only option is to disable autocomplete on this field, but I do not want to do that.

推荐答案

如果它让你感觉更好,那就是 已知错误

If it makes you feel better, it is a known bug

建议的解决方法:(不是我的,来自 这里

Proposed workaround: (Not mine, from here

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Mozilla Firefox Problem</title>
<script type="text/javascript">
function fOnChange()
{
  alert('OnChange Fired');
}

var val_textBox;

function fOnFocus()
{
  val_textBox = document.getElementById('textBox').value;
}

function fOnBlur()
{
  if (val_textBox != document.getElementById('textBox').value) {
    fOnChange();
  }
}
</script>
</head>
<body>
<form name="frm">
<table>
<tr>
<td><input type="text" id="textBox" name="textBox" onFocus="fOnFocus()" onBlur="fOnBlur()"></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</form>
</body>
</html>

这篇关于FireFox 捕获自动完成输入更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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