Even More Customization
At this point, you know enough to add Google Seach to your page. If you want to pull your sleeves up and customize Google Search further, continue reading this section. Otherwise, we recommend reading the Using the Wizards to Generate Code section. The team at Google has created some fun wizards that make it even easier to add fun search functionality to your web site.
Using Callbacks
The Google Search API has several callback methods. A callback
method is one that is triggered when an event takes place, such as
loading a page or completing a search. These are useful if you want to
perform an action based on a particular event. You have already seen the
setOnLoadCallback
method in action. This method is
called when the document containing the call is loaded.
Here is a complete list of the callback methods offered by the API, in alphabetical order:
setOnClearCallback
fromGSearchForm
: Called when the Clear button on the search form is clicked.setOnKeepCallback
fromGSearchControl
. Notifies caller when a user has selected for copy a search result.setOnLoadCallback
from theGSearch
base class. Calls a specified method when the document containing the call loads.setOnSubmitCallback
fromGSearchControl
. Called when the Search button is clicked, or when the Enter key is pressed while the search text input box has focus.setSearchCompleteCallback
fromGSearchControl
. Notifies caller upon the completion of a search.setSearchStartingCallback
fromGSearchControl
. Notifies ...
Get Google Ajax Search API now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.