”;
In this chapter, we will learn how to add a search option or a search box to the website. If it is a large site, then you will need to have a search box in the site so that the user can find any data easily. There are many free ones available such as Windows Live, Google, etc.
Windows Live Search
The following steps show you how to add a Windows Live Search box to your web page, and then set the search form to search the entire Web or only your website.
Step 1 − Create a new HTML page and call it SearchPage.
Step 2 − Go to the Format menu and select Dynamic Web Template → Attach Dynamic Web Template…option. Select the master.dwt file and click the Open button.
Step 3 − Let’s add the following code inside the editable region.
<form method = "get" action = "http://search.live.com/results.aspx"> <input type = "hidden" name = "cp" value = "1252"/> <input type = "hidden" name = "FORM" value = "FREESS"/> <table style = "background-color: #ffffff;"> <tr> <td> <a href = "http://search.live.com/"> <img src = "http://search.live.com/s/affillogoLive.gif" style = "border:0px;" alt = "Live Search"/> </a> </td> <td> <input type = "text" name = "q" size = "30" /> <input type = "submit" value = "Search Site"/> <input type = "hidden" name = "q1" value = "site:http://www.microsoft.com/expression"/> </td> </tr> </table> </form>
Step 4 − Save the page. Go to the File menu and select Preview in Browser.
Step 5 − You will see the Windows Live Search in your webpage. Let’s enter something in the search and click the Search Site button
Step 6 − As you can see that it will search on the web. If you want to restrict the search to only your website, then you have to specify your site domain in the following name instead of www.microsoft.com/expression
<input type = "hidden" name = "q1" value = "site:http://www.microsoft.com/expression"/>
Step 7 − Similarly, you can add the Google search option by adding the following code in the editable region.
<form method = "get" action = "http://www.google.com/search"> <div style = "border: 1px solid black; padding: 4px; width: 20em; margin: 0px auto 0px auto"> <table border = "0" cellpadding = "0"> <tr> <td class = "center"> <input type = "text" name = "q" size = "25" maxlength = "255" value = "" /> <input type = "submit" value = "Google Search" /> </td> </tr> <tr> <td align = "center" style = "font-size: 75%"> <input type = "checkbox" name = "sitesearch" value = " http://www.microsoft.com/expression" checked = "checked" /> Only search this website<br /> </td> </tr> </table> </div> </form>
Step 8 − Save your HTML page and you will see a search box, search button, checkbox, and checkbox label.
Step 9 − To restrict users to search only your website, select the checkbox and go to the Tag Properties panel and set the Value property to the URL of your website, such as www.microsoft.com/expression.
Step 10 − Save your page and preview it in the browser. Now you will see the Google Search option in your webpage.
”;