替换LBS站内搜索为google/baidu引擎

LBS自带的搜索其实做的不错,但由于不是全文检索并存在日文字符溢出的问题,我决定把它换掉。

为了操作方便,准备使用现成的站内搜索引擎代码。还好百度和google 都提供有相应的代码。

search

1.百度的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<form action="https://www.baidu.com/baidu" target="_blank">
<table bgcolor="#FFFFFF">
<tbody>
<tr>
<td>
<input name="tn" type="hidden" value="baidu"><br>
<a href="https://www.baidu.com/"><img src="https://img.baidu.com/img/logo-80px.gif" alt="Baidu" align="bottom" border="0"></a><br>
<input type="text" name="word" size="30"><br>
<input type="submit" value="百度搜索">
</td>
</tr>
</tbody>
</table>
</form>

如果你不需要百度的logo的话,可以把

1
<a href="https://www.baidu.com/"><img src="https://img.baidu.com/img/logo-80px.gif" alt="Baidu" align="bottom" border="0"></a><br>

去除

表单的样式也可以自行定义,你可以直接给 <form> 添加一个 id

例如:

1
<form action="https://www.baidu.com/baidu" target="_blank" id="searchBar">

然后在你使用的css中,可以对 searchBar及其下的元素进行定义,如:

1
2
3
#searchBar table{
background:#f4f4f4;font-size:12px;
}

诸如此类。。。

改好之后,把它放在global.asp中合适的位置即可

google

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<table bgcolor="#FFFFFF">
<tbody>
<tr>
<td>
<a href="https://www.google.com/intl/zh-CN/"><br>
<img src="https://www.google.com/logos/Logo_40wht.gif" border="0" alt="Google" align="absmiddle"></a><br>
<input type="text" name="q" size="31" maxlength="255" value=""><br>
<input type="hidden" name="ie" value="GB2312"><br>
<input type="hidden" name="oe" value="GB2312"><br>
<input type="hidden" name="hl" value="zh-CN"><br>
<input type="submit" name="btnG" value="Google 搜索">
</td>
</tr>
</tbody>
</table>

和百度的一样,放在gloabal.asp里合适的位置就可以了