Free tech support header

Can I add a Microsoft Bing search box to my site?

I know that Google is the popular search engine for most folk, but I really think that Microsoft's Bing system is better and offers up more useful results. To help Bing become more successful, I'd like to have a search box on my site that utilizes the Bing search engine. Is that possible?


Dave's Answer:

I agree with you that Bing is becoming quite a credible competitor to Google and that the results are show in a useful form, including info that Google just doesn't have. I'm not sure that it'll every overtake the Google behemoth, but then again, just because Ferrari doesn't sell more cars than Ford that doesn't mean it's not a cool car!

As with the other search systems I have unwrapped and reverse engineered on the site (including Google, Google Images and YouTube), the first step with figuring out how Bing works with search is to go onto the site itself and run a search, then look at the resultant URL.

A Bing search for "cherries" (get it?) produces its results against the URL:

http://www.bing.com/search?q=cherry&go=&form=QBLH&qs=n&sk=

Now we can unwrap this by knowing a bit about how method=get Web forms work:

action=http://www.bing.com/search
q=pattern
go=
form=QBLH
qs=n
sk=

Based on my experience reverse-engineering other search forms, I am going to start with the most minimal possible search box:

<form method=get action="http://www.bing.com/search">
<input type="text" name="q" />
<input type="submit" value="Go!" />
</form>

Here's how it looks when we actually include it here on the blog entry:

Try it. Type in a search query and click on "Go!" to see what happens.

Functional, but a bit boring. Let's make it a tiny bit more attractive by adding a bit of CSS:

<form method=get action="http://www.bing.com/search">
<div style="border:1px solid black;padding:5px;width:350">
<center> Search Bing: <input type="text" name="q" size="30" />
<input type="submit" value="Go!" />
</center>
</div>
</form>

Again, when I actually implement it here on the blog entry, this is what we get:

Search Bing:

So that's your answer. You can tweak and fiddle from here... :-)



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    

Subscribe!
Never miss another Q&A article! Click to subscribe: Add to Google Reader Add to My Yahoo! Subscribe in NewsGator RDF XML
Comments

Just curious why you use "<div style=...>" to set the style, but then use "<center>" separately. Couldn't that just be part of the div's style?

Posted by: Ken B at July 9, 2010 12:09 PM

Ken, experimentation will reveal what I have always found a huge disappointment and flaw in the CSS positioning attribute: it only centers text containers, not graphical containers. In other words, using <div style="text-align:center;"> will not actually center everything in that DIV tag, so I find that I still use the CENTER tags anyway. If there is another CSS attribute that centers everything in that DIV I would sure love to know about it!

Posted by: Dave Taylor at July 9, 2010 1:35 PM

Hmm... This works for me in Firefox 3.6.6, Safari 5.0, and IE 8.0. (Maybe the CSS specs don't specify that it should "work", but it does, anyway?)

<div style="text-align: center;">
<img src="photo.png">
</div>

Posted by: Ken B at July 12, 2010 8:25 AM

I have something to say, now that you mention it, but ...
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 for all your efforts on this Web site by buying you a cup of coffee!

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











Remember personal info?


Please note that I will never send you any unsolicited email. Ever.

While I'm at it, 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.






Recent Entries
Search
I Need Help!



Join The Club!
Sign up and get free weekly updates, news on my speaking schedule, seminars, workshops and more. It's cool. Just do it. :-)

© 2002 - 2010 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.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.