Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Trong phần này, chúng ta sẽ tạo ra một ứng dụng Google Search Ajax sử dụng dịch vụ Google tìm kiếm địa phương. Ajaxsearch.jsp thêm Google Ajax Search API thư viện JavaScript. Chỉ định Google Ajax Search API quan trọng trong các thuộc tính src cho các thẻ script. | 10.4 Creating a Google Ajax Web Search Application 199 Local Web Blog News Book Fig. 10.4 Tabbed Draw Mode The search results may be displayed in one of the three expansion modes open closed or partial. In the open expansion mode the search results are displayed fully. In the closed mode the search results are not displayed until a UI element such as an arrow is clicked. The partial search result displays partial results. The default expansion mode is partial. 10.4 Creating a Google Ajax Web Search Application In this section we shall create a Google Ajax Search application using the Google Local search service. To the ajaxsearch.jsp add the Google Ajax Search API JavaScript library. Specify the Google Ajax Search API key in the src attribute for the script tag. script src http www.google.com uds api file uds.js v 1.0 key ABQIAAAAItAEL-H-GuOHsDfD7MxmlhSFcmgG4ILrfBhrLV-hrgg2-UNeQhR4CSVn6vmsU_8IvmmjnIcWuaTufg type text javascript script Create a JavaScript function onLoad to add a search control and search service. In the onLoad function create a search control object. var searchcontrol new GSearchControl Set the result set size to GSearch.LARGE_RESULTSET which typically returns 8 results. searchControl.setResultSetSize GSearch.LARGE_RESULTSE T Create a GlocalSearch searcher object for the Google Local search service. var localsearch new GlocalSearch Add the searcher to the search control. searchControl.addSearcher localSearch 200 10 Web Search with Ajax Set the location for which the local search is to be performed with the setCenterPoint location method. localSearch.setCenterPoint Berlin Germany Create a GdrawOptions object to specify the draw options for the search results. var drawOptions new GdrawOptions Set the draw mode to linear. drawOptions.setDrawMode GSearchControl.DRAW_MODE_LINE AR Specify a div element to display the search control results. div id searchcontrol Loading div Activate the search control and display the results in the searchcontrol div. .