Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


How do I add a Yahoo search box to my site?

How do I add a Yahoo search box on my site? I can see you've written about Google, but Yahoo's impossible to decipher!


Dave's Answer:

I agree with you about how complex Yahoo's search code is. In fact, I think that deciphering the Yahoo home page source code could easily be the final exam of a graduate level computer science course. It's really unbelievably baffling!

Fortunately you can reverse engineer the search by simply looking at the URL that is produced when you do a Yahoo search, strip out the unnecessary variables, and then build a rudimentary HTML form that produces the remaining. Let me show you...

I'll do a Yahoo search for Microsoft Zune and here's the URL that's produced:

http://search.yahoo.com/search?p=microsoft+zune&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8

Now, within the Web browser's Address box, I'm going to experimentally remove specific name=value pairs to pare it down to the bare minimum. Turns out that the following much simpler URL produces the exact same search result:

http://search.yahoo.com/search?p=microsoft+zune

Nice! You can avoid all the other mumbo-jumbo, and thank goodness.

The form that produces that search looks like this:

<form method="get" action="http://search.yahoo.com/search">
<input type="text" name="p" />
&nbsp; <input type="submit" value="Search Yahoo!" />
</form>

That's all there is to it. Here's a Yahoo search box that has exactly that code underneath it:

 

One more tweak, though, just because that search box looks just a wee bit boring! You can drop in some minimal CSS and put a nice little box around the search form:

<form method="get" action="http://search.yahoo.com/search"
style="border:3px double black;padding:5px;">
<input type="text" name="p" />
&nbsp; <input type="submit" value="Search Yahoo!" />
</form>

Which now looks like this:

 

Hopefully that'll help you out!


Also check out:








Reader Comments To Date: 6

Dave said, on February 11, 2008 1:57 PM:

Using the above code worked fine but is it possible to have the search results open in a new page or tab(IE7)instead of navigating away from my website
Thank's
Dave

Dave Taylor said, on February 11, 2008 3:16 PM:

Dave, just add "target=_blank" within the FORM tag in the code above and you should have the behavior you seek.

Liz said, on February 20, 2008 7:42 AM:

Hi,

I am adapting the code to work with an affiliate programme. Problem is that I need to add other parameters to the URL.

Using your yahoo example it would be like I need the end URL to be:

http://search.yahoo.com/search?fr=yfp-t-501&p=microsoft+zune

I have tried making the action URL http://search.yahoo.com/search?fr=yfp-t-501&

But it strips off everything after the ? before adding the search term.

Raja said, on December 8, 2009 8:03 AM:

Hi....

I have developing a website using PHP. I want to integrate yahoo search into my website. I trying this code. The answer is display in new page. I want to display result in my page only. Is it possible?

Raja

Dave Taylor said, on December 8, 2009 8:29 AM:

Raja, no that's not possible, at least not easily. The easiest possibility would be to use an iframe for the search and search results, but you can't have a small search window and a large search results window. More complicated would be for you to write some software that would submit the search, get the results, and then embed the results in a page of your own. Complicated.

alis said, on February 19, 2011 12:10 AM:

pls sir add my site yahoo search engine

Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!

I do have a comment, now that you mention it!











I will never send you any unsolicited email. Ever.






 
Search
Need Help? Ask Dave Taylor!


Find Me on Google+
ADT on G+
© 2002 - 2013 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.