Microsoft Expression Web - 搜尋頁面



本章將學習如何在網站中新增搜尋選項或搜尋框。對於大型網站,需要在網站中新增搜尋框,以便使用者可以輕鬆找到任何資料。有很多免費的搜尋引擎可用,例如 Windows Live、Google 等。

Windows Live 搜尋

以下步驟將向您展示如何將 Windows Live 搜尋框新增到您的網頁,然後設定搜尋表單以搜尋整個網路或僅搜尋您的網站。

步驟 1 - 建立一個新的 HTML 頁面並將其命名為 SearchPage

SearchPage

步驟 2 - 轉到“格式”選單,然後選擇動態網頁模板 → 附加動態網頁模板…選項。選擇 master.dwt 檔案並單擊“開啟”按鈕。

Dynamic Template

步驟 3 - 讓我們在可編輯區域內新增以下程式碼。

<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>
Region

步驟 4 - 儲存頁面。轉到“檔案”選單,然後選擇“在瀏覽器中預覽”。

Save the Page

步驟 5 - 您將在網頁中看到 Windows Live 搜尋。讓我們在搜尋中輸入一些內容,然後單擊“搜尋網站”按鈕。

Search Site Button

步驟 6 - 您會看到它將在網路上進行搜尋。如果您想將搜尋限制在您的網站上,則必須在以下名稱中指定您的網站域名,而不是 www.microsoft.com/expression

<input type = "hidden" name = "q1" value = "site:http://www.microsoft.com/expression"/> 

步驟 7 - 同樣,您可以透過在可編輯區域中新增以下程式碼來新增 Google 搜尋選項。

<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>   

步驟 8 - 儲存您的 HTML 頁面,您將看到一個搜尋框、搜尋按鈕、複選框和複選框標籤。

Search Box

步驟 9 - 要限制使用者只搜尋您的網站,請選擇複選框,然後轉到“標籤屬性”面板並將“值”屬性設定為您的網站 URL,例如 www.microsoft.com/expression

CheckBox

步驟 10 - 儲存您的頁面並在瀏覽器中預覽。現在您將在網頁中看到 Google 搜尋選項。

Google Search Option
廣告
© . All rights reserved.