谷歌Ajax搜索
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了谷歌Ajax搜索相关的知识,希望对你有一定的参考价值。
<script src="http://www.google.com/jsapi?key={google_search_api_key}" type="text/javascript"></script> <script language="Javascript" type="text/javascript"> //<![CDATA[ var noResultsStr = "{no_results_str}" google.load("search", "1"); // Call this function when the page has been loaded function initialize() { // Dynamically load CSS to override defaults var options = new google.search.SearcherOptions(); options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN); var siteSearch = new google.search.WebSearch(); //siteSearch.setUserDefinedLabel("{tab_lbl}"); siteSearch.setUserDefinedClassSuffix("siteSearch"); siteSearch.setSiteRestriction("{google_cse}"); var searchControl = new google.search.SearchControl(); searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET); searchControl.addSearcher(siteSearch, options); searchControl.setNoResultsString(noResultsStr) // create a drawOptions object var drawOptions = new google.search.DrawOptions(); // tell the searcher what input field to use drawOptions.setInput(document.getElementById("{search_input_id}")); // tell the searcher to draw itself in tabbed mode drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED); searchControl.draw(document.getElementById("searchcontrol"), drawOptions); searchControl.execute(query); } google.setOnLoadCallback(initialize); //]]> </script>
以上是关于谷歌Ajax搜索的主要内容,如果未能解决你的问题,请参考以下文章
如何更改有关 GSnewsBar 对象(Ajax API)的“谷歌新闻”的语言?