1

I was wondering how i can make my own custom google search.

Can i do something like this :

<form action="http://www.google.com/search=q?+text input" method="get">
<input type="search">
<input type="submit">
</form>
Liam_Rab33
  • 69
  • 1
  • 8
  • Repeated question. You can find answers here http://stackoverflow.com/questions/275153/how-can-i-add-an-integrated-google-search-to-my-website – Nithin Jan 02 '14 at 10:31

3 Answers3

1

Try custom search api provided by Google for this. Though it is not pure HTML. The following code demonstrates how to render a search box, together with search results, in a div, using the explicit parsetag and function callback:

<div id="test"></div>

<script>
var myCallback = function() {
  if (document.readyState == 'complete') {
    // Document is ready when CSE element is initialized.
    // Render an element with both search box and search results in div with id 'test'.
    google.search.cse.element.render(
        {
          div: "test",
          tag: 'search'
         });
  } else {
    // Document is not ready yet, when CSE element is initialized.
    google.setOnLoadCallback(function() {
       // Render an element with both search box and search results in div with id 'test'.
        google.search.cse.element.render(
            {
              div: "test",
              tag: 'search'
            });
    }, true);
  }
};

// Insert it before the CSE code snippet so that cse.js can take the script
// parameters, like parsetags, callbacks.
window.__gcse = {
  parsetags: 'explicit',
  callback: myCallback
};

(function() {
  var cx = '123:456'; // Insert your own Custom Search engine ID here
  var gcse = document.createElement('script'); gcse.type = 'text/javascript';
  gcse.async = true;
  gcse.src = (document.location.protocol == 'https' ? 'https:' : 'http:') +
      '//www.google.com/cse/cse.js?cx=' + cx;
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
})();
</script>

This is the tutorial link.

Aditya
  • 2,876
  • 4
  • 34
  • 30
0

Google have their own walkthrough, https://www.google.com/cse/

webbist
  • 456
  • 4
  • 19
0

Please refer the following steps to create google custom search

1.First u have Sign up to Google Account

2.go to this url https://www.google.com/cse/create/new

3.Then specify the website URL (where to search )

4.click on Create button

5.in the next page there are 3 buttons available from that Click on "Get Code" Button.

6.after clicking on that, its generate the code. Copy that code and paste in your webpage.

Community
  • 1
  • 1
Yograj Sudewad
  • 343
  • 2
  • 9
  • This shall give you code for Search within Your website! While the question is for creating custom google search for web! – Aditya Jan 02 '14 at 11:14
  • 1
    in the custom google search you have suppose to specify at-least one website url and also you can do search settings through google account for any other searches – Yograj Sudewad Jan 02 '14 at 11:40