简体   繁体   中英

Google auto complete on search bar?

I have found many different ways to add auto complete to text inputs.

Such as: http://jqueryui.com/demos/autocomplete/

What I want is a way to not have to type all the possibilities that someone might type and instead just use Google's Autocomplete options. Like when you type in "dog", I get "dog breeds" "dogpile" and "dog the bounty hunter". I want the same thing to appear when I type in a text input. These tools that I have found require you to add in the options that the person could click.

Please let me know if you need anything explained further.

Thanks!

It's easily doable. Google provides an api for that:

http://suggestqueries.google.com/complete/search?client=firefox&q=dog

The client parameter is required.

Result:

["dog",["dog breeds","dogpile","dog the bounty hunter"],["","",""],[],{"google:suggesttype":["QUERY","QUERY","QUERY"]}]

Then it's your job to parse that and provide the info to your autocomplete plugin.


edit: I also found this way to access the api: http://google.com/complete/search?output=toolbar&q=microsoft from https://groups.google.com/forum/?fromgroups#!topic/google-ajax-search-api/UXTiCJMvKLo

And it seems like you can't use it for your site, at least according to this guy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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