If you know HTML, it’s relatively easy to make links to Google’s search results. Following each link in the examples below is the code that produces it.
See search results in the same browser window
[ Google tutorial create link ]
is generated from
[ <a href=”https://www.google.com/search?q=Google+tutorial+create+link”>Google tutorial create link</a> ]
See search results in a new window
Open a new window containing the search results for the query
[ Google tutorial create link ]
by adding target="_blank"
:
[ <a target=”_blank” href=”https://www.google.com/search?q=Google+tutorial+create+link”>Google tutorial create link</a> ]
Search link must be valid
The URL — that is, the text shown in Italics here: href="https://URL-GOES-HERE
” — must be valid. For instance:
- The URL shouldn’t contain any spaces. Use a plus sign (+) in place of each space.
- Certain characters can’t be used literally; they must be encoded into a form like
%nn
.
For example, the query [ “a song for you” ] would be encoded in a URL as https://www.google.com/search?q=%22a+song+for+you%22
, where each quote ("
) is replaced by %22
.
The easiest way to find the correct encoding is to type your query into a Google Search box. Then run the search and look at the resulting URL in your web browser’s address box (which is usually in the toolbar at the top of the window). Copy and paste the parts you need from the URL into your HTML code.
AdSense for Search
With AdSense for Search, you can easily create a revenue stream at the same time as provide a Google search box like the following.
Fill the search box with a query by specifying a value the attribute “value”, which AdSense for Search initializes to the null string (”").
Note: If you fill the search box with a query, Google may not share revenue with you.
AdSense for WebSearch + SiteSearch
AdSense for WebSearch + SiteSearch allows users to search the web or the specific site(s) of your choice.
Note: AdSense for Search centers the search box on the page while AdSense for WebSearch+SiteSearch doesn’t. Of course, you can modify the AdSense code to place the search box wherever you want on the page.
Exercises
These problems are intended to give you practice in creating links to Google’s search results.
- On one of your web pages, create a link to a Google search result.
- On one of your web pages, create a link that opens a new window and displays a Google search result.
- Use AdSense for Search to create a Google search box on a page in your website. You’ll need to sign up for an AdSense account first.
- On one of your web pages, using AdSense for WebSearch + SiteSearch, create a Google search box with a radio button for searching your site. Get an AdSense account before doing this problem.
tags (keywords): developing websites, search box, URLs