Skip to main content

September 18, 2007

Google Co-op Custom Search—Now With Less Evil

binoculars

Prompted by Khoi Vinh's excellent write-up, I recently implemented Google Co-op custom search on Luminous. This is site-specific search, the results of which appear on an in-site page that can be styled to more or less match the look of your site. It's a significant improvement over the previous Google offering, which published search results on a Google-hosted page with limited styling options.

Still, there are issues. The functionality is a bit difficult to implement due to shoddy and scattered documentation, and in-site results require purchase of the Business Edition, which at $100 a year is not exactly a bargain.

In the end I worked out the problems and forked up the dough but then was annoyed to discover how Google both uses and fails to use Javascript in delivering search results.

No Javascript, No Search Results

You hear this coming, don't you? Because Google uses Javascript to deliver the search results, users with Javascript turned off, as well as those using non-Javascript devices, will see zero search results. The search form will load the results page, but the page will be empty. I will spare you the rant about accessibility (and Google's disinterest in same) and cut to the solution.

Unobtrusive Javascript to the Rescue

The trick is to point the search form to the Google-hosted version of the results page (all Google Co-op custom search engines include one of these pages) and use a bit of unobtrusive Javascript to rewrite the path in the form's action attribute to point to your in-site results page. The upshot: users with Javascript will see in-site search results; those without it will see the Google-hosted version. (I know I said no rant, but really, why can't Google offer this functionality, at least as as an option? Could it be they lack the resources necessary to write a three-line Javascript function?)

If you'd like to give my approach a whirl, view source on any Luminous page to see how I set up the form, then check out the rewrite script. It's dirt simple: just change your search form to point to the Google-hosted version of your results page, then copy my little script and change the values to match those on your search form. Feel free to contact me if you have any questions.

permanent link Published in Accessibility, Luminous, Scripting, Search

Previous ArticleArchivesNext Article

What Is This?

helicopter

This is a blog about better websites—how they're made and what makes them better. Think of it as Apocalypse Now but with the word Apocalypse changed to Quality and the theme shifted from madness to best practices in web development. It's written by me, Michael Barrish.

Song of My Professional Self

Michael Barrish as a young, sexy Walt Whitman

I celebrate myself, and sing myself. I build bulletproof websites using web standards and related best practices. I work with designers and companies needing expert style and markup. Clear and sweet is my soul

Weblog Articles

Latest

Death of a Standardista
I have no interest in building kick-ass containers for crappy content.
Great Copywriting—Not for Robots
Neither for the faint of heart nor the narrow of mind.
The Death of TimesSelect and the Future of Web Advertising
There's a lesson in this, and it's not that information wants to be free.
Google Co-op Custom Search—Now With Less Evil
Google's in-site search made accessible.

Popular

Adblock Plus Must Die
An anarchist superhero comes from the future to rid humans of ads forever.
Clients and Copy
When the copy sucks, the website sucks.
Pipe Dream
I just solved a longstanding CSS problem: pipe lists.
Confessions of a Bad Designer
I'm a one-trick pony, and my trick doesn't necessarily work.

weblog archives

Feeds