ITeye博客

google ajax search 示例

fly.net.cn · 2007-08-11 16:18 · google api · Google · CSS · Ajax · JavaScript · XHTML · Markdown

xml 代码

  1. >
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  5. <title>Hello World - Google AJAX Search API Sampletitle>
  6. <link href="http://www.google.com/uds/css/gsearch.css" type="text/css" rel="stylesheet"/>
  7. <style type="text/css">
  8. body {
  9. background-color: white;
  10. color: black;
  11. font-family: Arial, sans-serif;
  12. font-size: small;
  13. margin: 15px;
  14. }
  15. .gsc-control { width : 400px; }
  16. style>
  17. <script src="http://www.google.com/uds/api?file=uds.js&v=1.0" type="text/javascript">script>
  18. <script type="text/javascript">
  19. function OnLoad() {
  20. // Create a search control
  21. var searchControl = new GSearchControl();
  22. var drawElement = document.getElementById("searchResults") ;
  23. var searchForm = document.getElementById("searchForm") ;
  24. // Add in a full set of searchers
  25. var localSearch = new GlocalSearch();
  26. searchControl.addSearcher(localSearch);
  27. searchControl.addSearcher(new GwebSearch());
  28. searchControl.addSearcher(new GvideoSearch());
  29. searchControl.addSearcher(new GblogSearch());
  30. searchControl.addSearcher(new GnewsSearch());
  31. searchControl.addSearcher(new GimageSearch());
  32. searchControl.addSearcher(new GbookSearch());
  33. // Set the Local Search center point
  34. localSearch.setCenterPoint("New York, NY");
  35. // create a drawOptions object
  36. var drawOptions = new GdrawOptions();
  37. // tell the searcher to draw itself in linear mode
  38. drawOptions.setDrawMode(GSearchControl.DRAW_MODE_LINEAR);
  39. // tell the searcher to draw itself in tabbed mode
  40. drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
  41. //  drawOptions.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
  42. drawOptions.setSearchFormRoot(searchForm);
  43. searchControl.draw(drawElement, drawOptions);
  44. // execute an inital search
  45. searchControl.execute("http://fly-net-cn.iteye.com/");
  46. }
  47. GSearch.setOnLoadCallback(OnLoad);
  48. script>
  49. head>
  50. <body>
  51. <table width="100%">
  52. <tr>
  53. <td class="content" valign="top" width="60%">
  54. <div id="content">
  55. <div id="searchResults">Loading...div>
  56. div>
  57. td>
  58. <td class="sidebar" width="40%">
  59. <div id="sidebar">
  60. <h2>Searchh2>
  61. <div id="searchForm">Loading...div>
  62. div>
  63. td>
  64. tr>
  65. table>
  66. body>
  67. html>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。