最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Google's predictive text as you type code example - wo auto suggest dropdown menu - Stack Overflow

programmeradmin6浏览0评论

Google's new predictive text predicts the search "as you type" in the box by showing the next characters in light gray font. Does anyone know of any code that does this? I am aware of the typical suggest drop down menus but I am looking for example code that does everything in the search box - without auto suggest dropdown menu.

Google's new predictive text predicts the search "as you type" in the box by showing the next characters in light gray font. Does anyone know of any code that does this? I am aware of the typical suggest drop down menus but I am looking for example code that does everything in the search box - without auto suggest dropdown menu.

Share Improve this question edited May 2, 2011 at 8:18 John 30.6k18 gold badges93 silver badges133 bronze badges asked Feb 9, 2011 at 17:57 AndrewAndrew 1672 gold badges4 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

i found one similar script here which suggest words like google when user type search query

https://sourceforge/projects/searchpuppy/files/

I'm not sure if there are any that exists, but the logic to build one seems simple enough.

It seems to me that the prediction is always the first item in the autoplete list. The prediction is displayed by having two text inputs with transparent backgrounds, one layered underneath the other. The bottom input will contain the prediction (silver text); The top input is where the user types.

As the user types, the autoplete finds a list of suggestions. Take the first suggestion and populate the prediction input with it.

Bind an onKeyPress event to the user-input box and watch for the user to press the right arrow key. If user presses it, populate the user-input box with the value of the prediction box.

发布评论

评论列表(0)

  1. 暂无评论