Click here to Skip to main content
15,881,588 members
Articles / Web Development / HTML
Tip/Trick

Search your web page with Google's Engine

Rate me:
Please Sign up or sign in to vote.
4.88/5 (7 votes)
17 Jan 2011CPOL 13.8K   3   4
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)


Written By
Team Leader
Spain Spain
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 5 Cool one. Pin
thatraja30-Mar-11 5:57
professionalthatraja30-Mar-11 5:57 
GeneralRe: Hey, thanks Thatraja! Pin
nereo.lopez31-Mar-11 20:43
nereo.lopez31-Mar-11 20:43 
GeneralReason for my vote of 4 because it helped me. was a new thin... Pin
ahsan sarfraz23-Jan-11 21:00
ahsan sarfraz23-Jan-11 21:00 
GeneralRe: Well, thanks for voting! Hope you can take advantage of it :... Pin
nereo.lopez23-Jan-11 21:35
nereo.lopez23-Jan-11 21:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.