//google.load(moduleName, moduleVersion, optionalSettings)该方法可以加载各个 AJAX API
//moduleName 是 API 的名称(例如 "maps" 或 "search")
//version 可以指定 API 模块的版本
//optionalSettings 可以为您作为 JavaScript 对象常量加载的 API 指定所有可选配置选项
google.load('search', '1');
function OnLoad() {
// Dynamically load CSS to override defaults
//配置呈现样式
var css = document.createElement('link');
css.href = '../../css/gsearch_green.css';
css.type = 'text/css';
css.rel = 'stylesheet';
document.getElementsByTagName('head')[0].appendChild(css);
// Create a search control
//创建一个搜索控件
var searchControl = new google.search.SearchControl();
// site restricted web search with custom label
// and class suffix
//限制站点搜索
var siteSearch = new google.search.WebSearch();
siteSearch.setUserDefinedLabel("Amazon.com");
siteSearch.setUserDefinedClassSuffix("siteSearch");
siteSearch.setSiteRestriction("amazon.com");
searchControl.addSearcher(siteSearch);
// site restricted web search using a custom search engine
//使用定制的搜索引擎搜索,下面提交自定义的搜索引擎的号码即可
siteSearch = new google.search.WebSearch();
siteSearch.setUserDefinedLabel("Product Reviews");
siteSearch.setSiteRestriction("000455696194071821846:reviews");
searchControl.addSearcher(siteSearch);
// standard, unrestricted web search
//调用没有限制的google搜索
searchControl.addSearcher(new google.search.WebSearch());
// site restricted blog search
//对限定博客进行博客搜索
var blogSearch = new google.search.BlogSearch();
blogSearch.setUserDefinedLabel("LJ Nintendo DS Blog");
blogSearch.setSiteRestriction("http://community.livejournal.com/nintendo_ds/");
searchControl.addSearcher(blogSearch);
// site restricted news search
//对限定新闻站点进行新闻搜索
var newsSearch = new google.search.NewsSearch();
newsSearch.setUserDefinedLabel("Seattle Times");
newsSearch.setSiteRestriction("Seattle Times");
searchControl.addSearcher(newsSearch);
// Establish a keep callback
//创建后退控件
searchControl.setOnKeepCallback(null, DummyClipSearchResult);
// tell the searcher to draw itself and tell it where to attach
//绘制呈现搜索结果
searchControl.draw(document.getElementById("searchcontrol"));
// execute an inital search
//预设搜索关键字
searchControl.execute("Nintendo DS");
}
function DummyClipSearchResult(result) {}
google.setOnLoadCallback(OnLoad, true);
订阅:
博文评论 (Atom)
0 评论:
发表评论