简体   繁体   English

移动本机键盘autosuggest阻止加载javascript自动完成小部件

[英]Mobile native keyboard autosuggest blocks loading of javascript autocomplete widget

The mobile device in question is any Android phone. 有问题的移动设备是任何Android手机。 I open firefox (btw, chrome doesn't cause this), go to a website like google search or IMDB and then type something in the search box. 我打开firefox(顺便说一下,chrome不会导致这种情况),去谷歌搜索或IMDB等网站,然后在搜索框中输入内容。 The native autocomplete activates above the keyboard as soon as I type the first letter. 输入第一个字母后,原生自动完成功能会在键盘上方激活。 But I don't get the suggestions drop-down below the search box! 但我没有得到搜索框下方的建议下拉菜单! It's only after I remove the native autosuggest (or autocomplete) that the javascript-enabled drop-down appears below the search. 只有在我删除本机自动提示(或自动完成)后,才能在搜索下方显示启用了javascript的下拉列表。

In google search, however, the browser autosuggest works immediately and appears along with the native autosuggest: 但是,在谷歌搜索中,浏览器autosuggest会立即生效,并与原生autosuggest一起显示:

Google的自动填充程序克服了原生自动填充功能

But in IMDB (or others like Amazon), the browser autosuggest is delayed or blocked by the phone's autosuggest (and does not appear until the user selects the phone's suggestion or clears it): 但在IMDB(或其他类似亚马逊)中,浏览器自动提示会被手机的自动提示延迟或阻止(并且在用户选择手机的建议或清除之前不会显示): IMDB的自动完成功能因本机自动完成而延迟

I think google is using "keydown" events to detect user typing but not sure how because it wasn't quite working after I tried writing a simple autocomplete myself locally. 我认为谷歌正在使用“keydown”事件来检测用户输入,但不确定如何,因为在我尝试在本地编写一个简单的自动完成后它不能正常工作。 The "autocomplete=off" attribute (either on the form or the target input field) is also not helping. “autocomplete = off”属性(在表单或目标输入字段上)也没有帮助。

How is it possible to not allow the native keyboard autosuggest delay or block the browser autosuggest? 如何不允许本机键盘自动提示延迟或阻止浏览器自动提示?

Use the input event to detect the change. 使用输入事件检测更改。

If you are using jQuery/zepto do this. 如果您使用jQuery / zepto执行此操作。

$(selector).bind('input', function(){
   //autocomplete logic
});

In native js 在土生土长的js

document.getElementById(selector).addEventListener('input', function(){
    //autocomplete logic
});

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

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