How To Customize Google Custom Search Engine Watermark Image And Search Button

ADVERTISEMENTS

google_custom_search_watermarkBefore starting this tutorial I would like to tell you I do not know weather this tutorial is legal or not, I do not know are we allowed to customize the Google Custom Search Engine (GCSE) or not, do it at your own risk. Today I am going to tell you, how you can change the watermark image and how to tweak the search button in GCSE. Lets start :

Customizing the textbox

Now, the GCSE code looks like this :

original gcse code javas12345cript

To change the watermark image, copy the javascript source link i.e http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en and open it in browser. When you will carefully look at the javascript code you can see an image link.

(function() { var f = document.getElementById(‘cse-search-box’); if (!f) { f = document.getElementById(’searchbox_demo’); } if (f && f.q) { var q = f.q; var n = navigator; var l = location; if (n.platform == ‘Win32′) { q.style.cssText = ‘border: 1px solid #7e9db9; padding: 2px;’; } var b = function() { if (q.value == ”) { q.style.background = ‘#FFFFFF url(http:\x2F\x2Fwww.google.com\x2Fcoop\x2Fintl\x2Fen\x2Fimages\x2Fgoogle_custom_search_watermark.gif) left no-repeat’; } }; var f = function() { q.style.background = ‘#ffffff’; }; q.onfocus = f; q.onblur = b; if (!/[&?]q=[^&]/.test(l.search)) { b(); } } })();

We have to perform the following steps to change the watermark image :

1. First copy all the javascript code and paste it in Notepad.

2. Now change the watermark.gif image link with your own desired image.

3. Now save the file as google.js and upload it on web.

4. Now, go back to the GCSE code and replace the javascript code with your own edited code i.e

edited gdcse code

5. And you are done.

For your ease you can download the original javascript code from here and edit the image link.

Customizing the Submit button

Customizing the submit button is very simple, we do not have to edit any javascript rather we will tweak the Style.css file.

Open style.css file and paste this code at the end

#SearchButton {
background:url(Your-Submit-Button-Image-Link-Here) no-repeat;
width:70px; }

Please note : Change the width according to the size of the button image.

Now, in the GCSE code look for

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

and change it to

<input type=”submit” name=”sa” value=” ” id=”SearchButton”>

Save you work and you are done!

I know its bit confusing and if you are facing any problem in using this tutorial, drop your comments and I’ll reply to to your queries as soon as possible.


If you like this post, you will love these :

  1. Submit Your Blog URL To 20+ Top Search Engines In Just A Single Click : Get Traffic From Search Engines : Part3
  2. How To Make Your Blogger Template Search Engine Optimized
  3. How To Customize Blockquote In Blogger
  4. How To Submit Your Blog To Google :Get Traffic From Search Engines : Part1
  5. How To Submit Your Blog To Yahoo : Get Traffic From Search Engines : Part2
  6. Improve Your Google Experience : Customize Google [ Firefox Addon ]
  7. Compare Google, Yahoo, and MSN With One Search

Gaganpreet Singh on July 11, 2009 | Filed Under Blogger Tricks, Google, Google Adsense, Wordpress

{ 1 trackback }

Custom Google Search bar/button « Bloggins
December 2, 2009 at 11:07 am

{ 15 comments… read them below or add one }

1 Markus July 11, 2009 at 1:22 pm

Thank you very much ! You were really helpful. ;)

Pay a visit to my website in a few days, I will have something ready that I only accomplished because of you !

Reply

2 Mayur July 11, 2009 at 9:40 pm

Thanks, I was looking for a way to customize the google search submit button.

Reply

3 Debajyoti Das July 12, 2009 at 9:29 am

Hey Gagan, Can We add custom Search Button to Adsense Search… I mean will it break TOS

Reply

4 Stefan July 14, 2009 at 12:48 am

This is actually great information. I’m using Google Custom Search as standard in one of my themes that I’m thinking about releasing for free. Unfortunately the height of Googles search-button is different depending on if you are using IE or FF.

Reply

5 Sourish Nath July 24, 2009 at 11:52 am

This post was really helpful.I have already incorporated it in my website.Working Fine.

Thanks ,

Regards ,
Sourish
(Admin)
OneTrickADay

Reply

6 resh1986 August 17, 2009 at 10:47 am

thx… Many usefull guides here. thx! well done!

Reply

7 Hanafi September 3, 2009 at 8:58 pm

Very helpfull, this is what i looking for…

Reply

8 Simon November 3, 2009 at 4:29 am

I was wondering if it was possible to not only change how the button looks but to have it centered under the search box instead of on the side?

Reply

9 Gagan November 3, 2009 at 9:17 am

I think its no possible. I’ll explore the settings and will let you know sooon. :)

Reply

10 Simon November 4, 2009 at 8:32 am

If its even possible it might not be easy. I’m glad I found this article though as I needed to use a custom button.

Reply

11 Simon November 4, 2009 at 2:19 pm

Ha! I figured it out. I thought whats the worst that could happen if I simply put some centering tags around it? I figured if it works it has to go somewhere, and it did… Centered right underneath the text box like I wanted.

But I still wasn’t happy as it puts it right under the text box with no space, and I want a space. I tried a break tag and it didn’t work. Then for heck of it I tried paragraph tags and it worked!

So there you have it. For anybody who wants to put the search button centered underneath the text box just use centering tags around the buttons code.

If you want the button centered under the text box with a space between the two use paragraph tags as well with the centering ones.

I haven’t tried this with a modified search button though only the stock one. I can’t see why it wouldn’t work though.

Reply

12 dot November 11, 2009 at 5:13 am

If modifying the search button and watermark are against the Adsense terms of service, and I’m pretty sure I read it somewhere, why would you want to change them and risk having your adsense account shut down and earnings confiscated?
Google offers a paid search service where you can customise these things.
So, be careful!

Reply

13 Pavan Somu November 22, 2009 at 7:51 am

Hi Gaganpreet I wanna say that Google will severely treat the coders who change the code. I read it some where. Its better to make a note at bottom of post that “Try at your own Rick”.

Reply

14 Matt December 22, 2009 at 12:24 pm

Hi, I’m having trouble finding the GCSE code on my webpage… if someone could just point me in the right direction I’d be most grateful. Thanks

Reply

15 Matt December 22, 2009 at 1:12 pm

Hi. Where do I find the GCSE Code? The code google gave me does doesn’t include what you’re saying I should change…

Reply

Leave a Comment

Previous post:

Next post: