javascript - Deciphering the Google Search API: how to refer to an argument passed into callback function? -
I am using Google Search API to load some search results in my page. I want to set an argument for the callback function which says which div should attach itself to the search results.
Callback function definition here, per Google:
.setSearchCompleteCallback (object, method, opt_arguments?)
Here's how I am: Finder .set search full callback (document, function) {alerts (opt_ragruments [0]. Id);}, new array (indude));
The documentation states: "Applications can optionally pass in the context argument using optical arguments, which then pass the specified method."
Yes - but how? I have passed in the context argument, but how do I reference it inside the function? I have just tried to call opt_arguments, but JS errors clearly show that it is not defined.
The document is.
Thank you! Actually, this is the following: You can bind to an event handler like this:
function searchable (message) {alert (message); } Function onload () {var searchControl = new google.search.SearchControl (); Var web search = new google.search.WebSearch (); SearchControl.addSearcher (websearch); SearchControl.draw (document.getElementById ("searchcontrol")); SearchControl.setSearchCompleteCallback (this, searchComplete, "searched!"); SearchControl.execute ('Google')} google.setOnLoadCallback (OnLoad);
The above example code "searched"! When it's over.
Comments
Post a Comment