New Blog Search

I have installed new Google Search AJAX API. If you are using non-Javascript and non-embeddable browser such as lynx/elinks/dillo, the search is in the left toolbar. Now, you can search my blog easily.

The script is simple and you can implements yours. Just sign in to Google Search AJAX API and it will generate a key, use the key for accessing the library. Want more? Visit this to sign up (you must have a google account first).

See the examples. Dear Lazy web, here's how I did:

1# I go to Layout -> Edit HTML. I add this to the code in head section:

[script src='http://www.google.com/jsapi?key=$YOUR_GENERATED_KEY_HERE" type='text/javascript/]
[script language='Javascript' type='text/javascript']
//
google.load("search", "1");

function OnLoad() {
// Create a search control
var searchControl = new google.search.SearchControl();

// Add in a full set of searchers
// site restricted blog search
var blogSearch = new GblogSearch();
blogSearch.setUserDefinedLabel("JP Was Here!!!");
blogSearch.setSiteRestriction("http://jpmrblood.blogspot.com/");
searchControl.addSearcher(blogSearch);


// Tell the searcher to draw itself and tell it where to attach
searchControl.draw(document.getElementById("searchcontrol"));

// Execute an inital search
// searchControl.execute("install");
}
google.setOnLoadCallback(OnLoad);

//]]>
[/script]


Then, I save the code. If you pay attention, I only modify the example with stripping it down and left only the thing that I need. But, it can be installed with other things like video search etc. Btw, don't forget to change the $YOUR_GENERATED_KEY_HERE with your key and change the restriction with your own blog.

#2 Then go to Layout -> Page Elements. To add a widget container for our blog, click on "Add a Page Element" and choose the "HTML/JavaScript" part. Put this on the widget's content:

[div id="searchcontrol"]Loading...[/div]


and save it. Done.

Because of the restriction of Blogger, I think you could just see my page's source code.


Reference:
[1] http://ajaxsearch.blogspot.com/
[2] http://googleajaxsearchapi.blogspot.com/2007/07/ajax-search-on-blogger-and-linked.html

Comments

Popular Posts