Guest User

Untitled

a guest
Jun 26th, 2012
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. google custom search can't work
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-hans" xml:lang="zh-hans">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>test</title>
  7. </head>
  8. <body>
  9. <div class="fr_search">
  10. <form action="cse.php" accept-charset="UTF-8" method="post" id="search-theme-form">
  11. <input type="text" maxlength="128" name="search_theme_form" id="edit-search-theme-form-1" size="15" value="" class="form-text" />
  12. <input type="image" name="submit" id="edit-submit" class="form-submit" src="images/search_btn_top.gif" /></div>
  13. </form>
  14. </div>
  15. </body>
  16. </html>
  17.  
  18. <html xmlns="http://www.w3.org/1999/xhtml">
  19. <head>
  20. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  21. <title>test search</title>
  22.  
  23. </head>
  24. <body>
  25. <script src="http://www.google.com/jsapi" type="text/javascript"></script>
  26. <script type="text/javascript">
  27. google.load('search', '1', {language : 'en'});
  28. google.setOnLoadCallback(function() {
  29. var customSearchControl = new google.search.CustomSearchControl ('011247711644571852159:xe2ytn1hwsa');
  30. customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  31. customSearchControl.draw('cse');
  32. }, true);
  33. </script>
  34. <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
  35. <?php echo 'test'; ?>
  36. </body>
  37. </html>
  38.  
  39. <div id="cse">Loading&hellip;</div>
  40. <script src="http://www.google.com/jsapi"></script>
  41. <script>
  42.  
  43. // Extract user's query from the URL
  44. function getQuery() {
  45. var url = '' + window.location;
  46. var queryStart = url.indexOf('?') + 1;
  47. if (queryStart > 0) {
  48. var parts = url.substr(queryStart).split('&');
  49. for (var i = 0; i < parts.length; i++) {
  50. if (parts[i].length > 2 && parts[i].substr(0, 2) == 'q=') {
  51. return decodeURIComponent(parts[i].split('=')[1].replace(/+/g, ' '));
  52. }
  53. }
  54. }
  55. return '';
  56. }
  57.  
  58. google.load('search', '1', {language:'en' });
  59. google.setOnLoadCallback(function() {
  60. var cseControl = new google.search.CustomSearchControl('ID_GOES_HERE');
  61. cseControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  62. cseControl.draw('cse');
  63. // Execute a query based on the query string
  64. cseControl.execute(getQuery());
  65. }, true);
  66. </script>
  67.  
  68. <form action="cse.php" method="get">
  69. <input name="q"> <input type="submit">
  70. </form>
Advertisement
Add Comment
Please, Sign In to add comment