Advertisement
nicuf

Integrate-Google-Bar-Search

Jul 26th, 2021
2,626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.06 KB | None | 0 0
  1. English:
  2.  
  3. See explanation here:
  4. https://neculaifantanaru.com/en/how-can-i-integrate-google-search-box-to-my-website-by-implementing-custom-code.html
  5.  
  6. -----------
  7.  
  8. <form action="https://neculaifantanaru.com/search.html" method="get" id="site-search">
  9.     <fieldset>
  10.         <!-- <label for="search">Search in website</label> -->
  11.         <input type="text" name="q" id="q" value="" />
  12.         <button type="submit" class="btn btn-inverse">search</button>
  13.     </fieldset>
  14. </form>
  15.  
  16. -------------
  17.  
  18. <script>
  19.   (function() {
  20.     var cx = 'YOUR-NUMBER-CODE';
  21.     var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
  22.     gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
  23.         '//www.google.com/cse/cse.js?cx=' + cx;
  24.     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
  25.   })();
  26. </script>
  27.  
  28. -----
  29.  
  30. <div class="main-content">
  31. <h1>Search the site</h1>
  32.  
  33. <gcse:searchbox-only></gcse:searchbox-only>
  34. <gcse:searchresults-only></gcse:searchresults-only>
  35. </div>
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement