- Microsoft Expression Web 教程
- MS Expression Web - 主页
- MS Expression Web - 概述
- 环境设置
- MS Expression Web - 新网站
- 空白网页
- 网页布局
- MS Expression Web - HTML 布局
- 水平导航
- 垂直导航
- MS Expression Web - 验证页面
- 动态网页模板
- MS Expression Web - 搜索页面
- MS Expression Web - 图像
- MS Expression Web - 超链接
- MS Expression Web - 视频
- SQL数据源
- MS Expression Web - MS Word
- MS Expression Web - Gridview
- MS Expression Web - 母版页
- MS Expression Web - 数据表
- MS Expression Web - 发布
- 备份网站
- MS Expression Web - 插件
- MS Expression 网络资源
- MS Expression Web - 快速指南
- MS Expression Web - 资源
- MS Expression Web - 讨论
Microsoft Expression Web - 搜索页面
在本章中,我们将学习如何向网站添加搜索选项或搜索框。如果它是一个大型网站,那么您将需要在网站中设置一个搜索框,以便用户可以轻松找到任何数据。有许多免费的可用,例如 Windows Live、Google 等。
Windows 实时搜索
以下步骤向您展示如何将 Windows Live 搜索框添加到您的网页,然后将搜索表单设置为搜索整个 Web 或仅搜索您的网站。
步骤 1 - 创建一个新的 HTML 页面并将其命名为SearchPage。
步骤 2 - 转到“格式”菜单并选择“动态 Web 模板”→“附加动态 Web 模板...”选项。选择 master.dwt 文件并单击“打开”按钮。
步骤 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>
步骤 4 - 保存页面。转到“文件”菜单并选择“在浏览器中预览”。
步骤 5 - 您将在网页中看到 Windows Live Search。让我们在搜索中输入一些内容,然后单击“搜索站点”按钮
步骤 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 页面,您将看到搜索框、搜索按钮、复选框和复选框标签。
步骤 9 - 要限制用户仅搜索您的网站,请选中该复选框并转到“标记属性”面板,并将“值”属性设置为您网站的 URL,例如www.microsoft.com/expression。
步骤 10 - 保存页面并在浏览器中预览。现在您将在网页中看到 Google 搜索选项。
