Google AJAX 搜索 API文档:http://code.google.com/intl/zh-CN/apis/websearch/docs/ 复制代码 代码如下: Google AJAX 搜索 API <BR>#searchcontrol .gsc-control <BR>{ <BR>width: 100%; <BR>} <BR>#searchcontrol .gsc-result-cnblogs .gs-title <BR>{ <BR>color:Red; <BR>} <BR> type="text/javascript"> <BR>google.load("search", "1"); <br><br>function OnLoad() { <BR>//搜索设置 <BR>var options = new google.search.SearcherOptions(); <BR>//当搜索结果为空时显示内容 <BR>options.setNoResultsString('查询结果为空!'); <br><br>//搜索控件实例化 <BR>var searchControl = new google.search.SearchControl(); <BR>//每次显示8个搜索结果(取值范围:1-8) <BR>searchControl.setResultSetSize(8); <br><br>//网页搜索 <BR>var siteCnblogs = new google.search.WebSearch(); <BR>//标头 <BR>siteCnblogs.setUserDefinedLabel("脚本之家"); <BR>//样式后缀名 <BR>siteCnblogs.setUserDefinedClassSuffix("jb51"); <BR>//站点限制 <BR>siteCnblogs.setSiteRestriction("jb51.net"); <BR>searchControl.addSearcher(siteCnblogs, options); <br><br>//局部搜索 <BR>var siteZjfree = new google.search.WebSearch(); <BR>siteZjfree.setUserDefinedLabel("素材搜索"); <BR>siteZjfree.setSiteRestriction("sc.jb51.net"); <BR>searchControl.addSearcher(siteZjfree, options); <br><br>//全网搜索 <BR>searchControl.addSearcher(new google.search.WebSearch(), options); <br><br>//添加博客搜索 <BR>searchControl.addSearcher(new google.search.BlogSearch(), options); <br><br>//添加视频搜索 <BR>searchControl.addSearcher(new google.search.VideoSearch(), options); <br><br>//添加新闻搜索 <BR>searchControl.addSearcher(new google.search.NewsSearch(), options); <br><br>//添加图片搜索 <BR>searchControl.addSearcher(new google.search.ImageSearch(), options); <br><br>//添加本地地图搜索 <BR>var localSearch = new google.search.LocalSearch(); <BR>//地图中心标记 测试时可使用“大雁塔” <BR>localSearch.setCenterPoint("西安,钟楼"); <BR>searchControl.addSearcher(localSearch, options); <br><br>//绘制搜索 <BR>var drawOptions = new google.search.DrawOptions(); <BR>drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED); <BR>searchControl.draw(document.getElementById("searchcontrol"), drawOptions); <br><br>//执行搜索查询 <BR>searchControl.execute("google api"); <BR>} <br><br>//框架加载完成后调用 <BR>google.setOnLoadCallback(OnLoad); <BR> 加载中...