Advertisement
salmancreation

You would particularly be interested in Custom Search Elemen

Mar 8th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.39 KB | None | 0 0
  1. <div id="test"></div>
  2.  
  3. <script>
  4. var myCallback = function() {
  5.   if (document.readyState == 'complete') {
  6.     // Document is ready when CSE element is initialized.
  7.     // Render an element with both search box and search results in div with id 'test'.
  8.     google.search.cse.element.render({
  9.           div: "test",
  10.           tag: 'search'
  11.    });
  12.   } else {
  13.     // Document is not ready yet, when CSE element is initialized.
  14.     google.setOnLoadCallback(function() {
  15.        // Render an element with both search box and search results in div with id 'test'.
  16.         google.search.cse.element.render(
  17.             {
  18.               div: "test",
  19.               tag: 'search'
  20.             });
  21.     }, true);
  22.   }
  23. };
  24.  
  25. // Insert it before the CSE code snippet so that cse.js can take the script
  26. // parameters, like parsetags, callbacks.
  27. window.__gcse = {
  28.   parsetags: 'explicit',
  29.   callback: myCallback
  30. };
  31.  
  32. (function() {
  33.   var cx = '008717607452966325908:cegvvfhkhvk'; // Insert your own Custom Search engine ID here
  34.   var gcse = document.createElement('script'); gcse.type = 'text/javascript';
  35.   gcse.async = true;
  36.   gcse.src = (document.location.protocol == 'https' ? 'https:' : 'http:') +
  37.       '//www.google.com/cse/cse.js?cx=' + cx;
  38.   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
  39. })();
  40. </script>
  41.  
  42.  
  43.  
  44. #test input {
  45.   font-size: 32px;
  46.   color: red;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement