除左我想要既 site specific 既 search function 之外, Google AJAX Search API 介紹左好多大家少用既 search 功能:
- GlocalSearch – 同 Map search 有關, 搵有 geo tag 既網頁
- GwebSearch – 一般網頁搜尋
- GvideoSearch – 搵 tag 左既 video
- GblogSearch – 集中係 blog
- GnewsSearch – 新聞 search
- GimageSearch – 搵 tag 左既圖片
- GbookSearch – 搵書
有冇用就見仁見智, 因為除左 map, video 同 image, 其他都預設係 Google 本身個 search 度, 除左想特定搜尋, 如果唔係冇乜用
function OnLoad2() { var searchControl2 = new GSearchControl(null);
// Set the Local Search center point var localSearch = new GlocalSearch(); localSearch.setCenterPoint("Hong Kong");
// add in a full set of searchers searchControl2.addSearcher(new GimageSearch()); searchControl2.addSearcher(new GwebSearch()); searchControl2.addSearcher(new GvideoSearch()); searchControl2.addSearcher(new GblogSearch()); searchControl2.addSearcher(new GnewsSearch()); searchControl2.addSearcher(new GbookSearch()); searchControl2.addSearcher(localSearch);
// create a drawOptions object var drawOptions = new GdrawOptions();
// tell the searcher to draw itself and tell it where to attach // Note that an element must exist within the HTML document with id "search_control2" drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED); searchControl2.draw(document.getElementById("search_control2"), drawOptions);
// Execute an inital search searchControl2.execute("orz"); } google.setOnLoadCallback(OnLoad2);
係唔係仲多過 Google 本身個 search 呢, 其實仲有個Map Search, 但遲下先介紹, 因為仲多野玩, 至於個 source code:
[geshi lang=java]
function OnLoad2() { var searchControl2 = new GSearchControl(null);
// Set the Local Search center point var localSearch = new GlocalSearch(); localSearch.setCenterPoint("Hong Kong");
// add in a full set of searchers searchControl2.addSearcher(new GimageSearch()); searchControl2.addSearcher(new GwebSearch()); searchControl2.addSearcher(new GvideoSearch()); searchControl2.addSearcher(new GblogSearch()); searchControl2.addSearcher(new GnewsSearch()); searchControl2.addSearcher(new GbookSearch()); searchControl2.addSearcher(localSearch);
// create a drawOptions object var drawOptions = new GdrawOptions();
// tell the searcher to draw itself and tell it where to attach // Note that an element must exist within the HTML document with id "search_control2" drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED); searchControl2.draw(document.getElementById("search_control2"), drawOptions);
// Execute an inital search searchControl2.execute("orz"); } google.setOnLoadCallback(OnLoad2);
[/geshi]





