fcOnTheWeb Logo Web technologies, made easy.

fcOnTheWeb Red DotHow to add a Google search box to a web page

Adding a Google search box to your website is just about as easy it was to add YouTube videos to your website. After a little bit of digging around the Google site, we find that Google is giving away the code to add the search box to your site!


This is the code Google gives us:

<!-- Use of this code assumes agreement with the Google Custom Search Terms of Service. -->

<!-- The terms of service are available at /coop/docs/cse/tos.html -->

<form name="cse" id="searchbox_demo" action="http://www.google.com/cse">

<input type="hidden" name="cref" value="" />

<input type="hidden" name="ie" value="utf-8" />

<input type="hidden" name="hl" value="" />

<input name="q" type="text" size="40" />

<input type="submit" name="sa" value="Search" />


<script type="text/javascript" src="http://www.google.com/cse/tools/onthefly?form=searchbox_demo&lang=">

And now adding the Google search bar to your web page is as easy as pasting that code in where you want it. The way it appears on the page is shown below:

Customising the search box (a little, within Google's guidelines - these guidelines, and these ones...) is easy too. What we are going to do is style the button to match the others on our site and change the text on the button.

To style the button, we simply add out predefined class: class="form_button". And to change the text we simply change the value attribute to be whatever we want. It looks like this:

<input type="submit" name="sa" value="Search with Google" class="form_button" />

So our implementation can be found on our search page, and looks like this:

The logo does not show in this box and the box does not actually work specifically to our site because Google's JavaScript does not work with more than one instance of the search bar on any one page. We can't edit the JavaScript, so there is not much that can be done about that. But as long as you do not have more than one instance on a page, it will be fine.

Google gets its search results from pages linked to by the page the search is on, as well as its cached results for that domain. So, the search on this article page in particular is inaccurate as it brings up a host of results from Google itself, due to the preceeding links to Google in the text. However, the one implemented on our Search page does a much better job of it.

To finish off, it is worth noting that Google provides a lot more options through its paid service, Google Site Search. These features allow you to keep the search results on your domain, add a custom header and style the results to match your theme - but it comes with a price.


Harua Ishaq (http://inyass4ishaq.gnbo.com.ng) says:

2012-08-10 09:01:46

adding of a google search page to mu web site


Cheap Ralph Lauren UK (http://cheapralphlaurenuk.1minutesite.co.uk/) says:

2014-01-18 03:02:51

Gucci Shoes UK, http://www.guccivshoesfactory.net/
Polo Ralph Lauren Outlet Online, http://www.rralphlaurenoutlet.com/
Ralph Lauren Outlet Online, http://www.ralphlaurenipolo.com/
Ralph Lauren UK, http://www.polo-outletstoreonline.com/
Beats by Dre, http://www.discountbeatsbydresale.com/
Sacs Longchamp Pairs, http://www.saclongchamppairs.com/
Canada Goose Outlet, http://www.thecanadagooseoutlet.com/
Hollister UK Shops, http://www.cheaphollistersale.co.uk/
Michael Kors Outlet Online, http://www.michaelkors.so/
Marc Jacobs Outlet, http://www.marcjacobsonsale.com/
Michael Kors Outlet, http://www.michaelkorsr.com/
North Jackets Clearance, http://www.north-faceoutletonlines.net/
Burberry Outlet Online, http://www.burbagssale2013.com/
North Clearance Outlet Online, http://www.north-clearance.com/
Coach Factory, http://www.coach-factories.com/
Coach Outlet Online, http://www.coach-purseonsale.com/
Cheap Ralph Lauren UK, http://cheapralphlaurenuk.1minutesite.co.uk/
Michael Kors Outlet
Discount Michael Kors
Michael Kors Outlet
Michael Kors Factory Store
Michael Kors Outlet
Discount micheal kors


mbt usa (http://www.mbtiuk.com/) says:

2014-04-16 07:07:04

Mbt shoes are able to help you solve the problem of physical ache. When Legs and feet are twisted, when back and hips are ached, when joint and muscles or ligaments get hurt, mbt shoes are helpful to these pains\' recovery.


cheap mbt shoes (http://www.mbtclearanceukoutlet.com) says:

2014-07-03 08:12:21

Brasilian pelaajat Scolari psykologinen ep├Ątasapaino psykiatri apua http://www.mbtclearanceukoutlet.com


oakley sunglasses cheap (http://www.oakleysunglassescheap.us.com/) says:

2014-07-12 07:02:40

http://www.oakleysunglassescheap.us.com/ oakley sunglasses

http://www.coachoutletstoreonlineco.com/ coach factory outlet
http://www.abercrombie-andfitch.com/ abercrombie and fitch
http://www.michaelkors-outletsonline.com/ michael kors outlet
http://www.oakley-sunglassesoutlet.com/ oakley sunglasses

http://www.tory-burchoutlet.com/ tory burch outlet
http://www.abercrombieandfitchstore.com/ abercrombie & fitch
http://www.rayban--sunglasses.com/ ray ban sunglasses
http://www.fit-flops.co.uk/ fitflops
http://www.coachoutlet-factoryonline.com/ coach factory outlet
http://www.toryburch-shoes.com/ tory burch shoes
http://www.coachstoreonline.org/ coach outlet store online
http://www.coachfactory-outletinc.com/ coach factory outlet
http://www.cheapraybansunglasses.us/ cheap ray ban sunglasses
http://www.valentino.us.com/ valentino
http://www.fitfloponline.co.uk/ fitflop uk
http://www.coach-outletinc.com/ coach outlet
http://www.coachoutlet-factorystore.com/ coach outlet store

http://www.airjordan.us.com/ air jordan
http://www.timberlandshoesus.com/ timberland shoes
http://www.michaelkorsoutlet-online.us/ michael kors outlet
http://www.coachfactoryoutletnew.com/ coach factory outlet
http://www.coach-factoryoutletinc.com/ coach factory outlet
http://www.truereligionbrandjeans.us.com/ true religion outlet
http://www.truereligionjeans.us.com/ true religion jeans
http://www.coach--handbags.com/ coach outlet online
http://www.louisvuitton--outlet.us/ louis vuitton outlet
http://www.timberland--shoes.com/ timberland boots
http://www.isabelmarantshoes.us.com/ isabel marant shoes
http://www.coachoutletonline-factory.com/ coach outlet online
http://www.michaelkorsoutlet-online.net/ michael kors purses
http://www.louisvuitton-handbag.us/ louis vuitton handbags
http://www.coach-outletstoreonline.com/ coach outlet store

http://www.true-religion-jeans.com/ true religion jeans
http://www.coach-outletfactoryonline.com/ coach factory outlet

http://www.officialcoachfactoryoutlet.com/ coach factory outlet
http://www.louisvuitton-outlet.org/ louis vuitton outlet
http://www.coach-factoryoutlets.com/ coach factory outlet
http://www.coach-outletonline.us/ coach outlet online
http://www.michaelkorsoutletonlinestore.us/ michael kors outlet
http://www.michaelkorsoutletstoresco.com/ michael kors outlet

http://www.tiffanysjewelry-co.com/ tiffany and co jewelry
http://www.celineoutlet-online.com/ celine outlet
http://www.cheap-toms.net/ toms shoes
http://www.celine-handbags.com/ celine handbags
http://www.toms--shoes.us/ toms outlet
http://www.fitflopsandalssale.com/ fitflops
http://www.fitflopusaonline.com/ fitflop outlet
http://www.prada-handbag.com/ prada handbags
http://www.tiffanyandcoinc.com/ tiffany jewelry
http://www.prada-outlet.org/ prada outlet
http://www.michael-korsoutletinc.com/ michael kors
http://www.marcjacobs.us.com/ marc jacobs
http://www.supra.us.com/ supra shoes
http://www.ralphlauren.us.com/ polo ralph lauren
http://www.tiffanyjewelry.us.com/ tiffany jewelry
http://www.shoestoms.net/ toms shoes

Add your comment on this article below:

Sorry, there's an error with your form entries. We really appreciate your comment, so please try again.

Form submitting now...



Email address (not displayed):

Enter your comment below: