Easy Code to Add Bing Site Search to Your Website


If your website consists of more than just a few pages, it's important to have a way for your visitors to search your website. There are several ways you can accomplish this. One way is to use a pay site search company which will index your site's contents and provide you code for a search box. This may give you more control over the results returned for a specific search. But, the down side is, you have to pay.

Another way to put site search to your website is to create your own index of your site's contents and write your own search program. This gives you complete control over the results returned. The down side, it's very complicated to write code that can create an index and return results from that index based upon a specific search term or phrase.

Another way is to simply put the code for a search box that calls the search program of one of the major search providers, like Bing. Bing is Microsoft's attempt to steal some of that lucrative search traffic from Google. The name "Bing" comes from the phrase "Because it's not google". Bing is very powerful, so if you're anti-Google, you may choose to implement a Bing search box. The down side is that Microsoft is in the search business to make money, so there will be some not from you're website results returned with your sites results.

The code for Bing site search is shown below, just paste this code into the desired location on your website.

<form method="get" action="">
   <input type="hidden" name="cp" value="1252" ?>
   <img src="" alt="Bing" /></a>
   <input type="text" name="q" size="30" maxlength="255" />
   <input type="submit" value="Search Site" />
   <input type="hidden" name="q1" value="" />

One thing you'll want to do is replace the text "" with the URL of your website (unless you want to post a form to search my website. In that case thank you.) And just above that you may want to replace the text "Search Site" with "Search (the name of your website)". Or just leave it "Search Site".

After you make those modifications, type in a search term or phrase and give it a test. You can't get the services of a powerful search engine on your website any easier or cheaper than this.

Note: Some people don't like their visitors being redirected away from their website to Microsoft's search site. To avoid that, in the top line of the code and add the target attribute as shown below.

<form method="get" action="" target="_self">

The target "_self" will cause the contents of your window to be replaced with bing's results. If you use the target "_blank" instead, a new window will be created and bing's results will be in that new window.

More HTML Code:
• Line Breaks in HTML
• Easy Form Design
• HTML5 Header Element
• Use HTML Target Attribute to Specify Where to Open Document
• Make an HTML Element Editable
• Image Map Basics
• HTML Special Characters - Character Entities
• Form Input Labels
• Easy Code to Add Yahoo Site Search to Your Website
• Using col and colgroup to Apply Attributes to a Table Column