Get Google Ajax Search For Your Site UPDATE

If you read my recent post, How to Get Google AJAX Search For Your Site, and used it to implement the Google Ajax Search control on your blog or website, this post is for you.

When I replaced the old Google Search box with the newer Google Ajax Search for my blog, I quickly realized that there was no way to clear the search results from the screen. That’s why I wrote the function “searchControlClear()” that I described previously. Since writing that post, Google has included the clear functionality natively into the search control, so some changes could be made to make things work more smoothly.

These are the changes I made to use Google’s built in function instead of my own. In your javascript, you need to make two changes: one at the beginning and one at the end. First, move this line of code:

var searchControl = new GSearchControl();

to the line above this line of code:

function onLoad()

So the beginning of your javascript should look like this:

//<![CDATA[
var searchControl = new GSearchControl();
function onLoad()
{
function MyBlogSearch()
{
.
.
.

The second change you need to make is at the end of your javascript code. Inside the searchControlClear() function, replace everything with this:

searchControl.clearAllResults();

So your function should look like this:

function searchControlClear()
{
searchControl.clearAllResults();
}

Try this on for size!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: