Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / HTML

Search your web page with Google's Engine

4.88/5 (7 votes)
17 Jan 2011CPOL 14.6K  
Search your web page with Google's Engine
Hi everyone,
This time I want to show how you can add a search text box in your web page using Google's search engine, so you can get full search functionality without writing any code, no matter what programming language you use.

HTML Code


HTML
<form action="http://www.google.com/search" method="get" name="searchform" target="_blank">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
  <td>
    <input name="sitesearch" type="hidden" value="http://nereolopez.blogspot.com" />
  </td> 
  <td>
    <input alt="search" name="as_q" size="20" type="text" value="Search this web" />
  </td> 
  <td>
    <input title="Search" type="submit" value="Search" />
  </td> 
</tr>
</tbody>
</table>
</form>

Explanation


This is just an HTML form which contains a hidden field with the URL where we want Google to search, an input (TextBox) where user can input what he/she wants to search, and a submit button.

The ACTION of the form is the Google's Search Engine URL and will be opened in a new tab in the browser when user clicks the submit button.
As we are using the GET method, the resulting URL would be something like this:

http://www.google.com/search?sitesearch=nereolopez.blogspot.com&as_q=silverlight

Working Example


If you want to check how it works, just check this example.
Hope you like it. As ever, please feel free to leave any comment, suggestion or question.

Thanks for reading!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)