如果你也是一个站长的话,是不是也想让自己的网站搜索加入到浏览器搜索框中呢?好的,下面我就说明如何添加
1. 制作XML,让浏览器感应到。XML代码如下
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<InputEncoding>GBK</InputEncoding>
<OutputEncoding>GBK</OutputEncoding>
<ShortName>3qit 文章搜索</ShortName>
<Tags>3qit IT</Tags>
<Description>Description</Description>
<Image height="16" width="16" type="image/vnd.microsoft.icon">http://www.3qit.com/favicon.ico</Image>
<Url type="text/html" template="http://www.3qit.com/search.php?keywords={searchTerms}"/>
<AdultContent>false</AdultContent>
<Developer>zol Ltd. Team</Developer>
</OpenSearchDescription>
上面代码中以红色标记的请修改为你网站相应的信息,如果你网站搜索页是以UTF-8编码的,那么InputEncoding和OutputEncoding都写成UTF-8就行了。其中ShortName就是搜索框中要显示的名称,Description是简介。Image是搜索框前面要显示的小图标,Url就是搜索链接了,其中{searchTerms}是关键字,你根据自己程序的URL自行修改其位置。下面的几个标签就不太重要了,可以可无。
2. 制作好了以后,把这个XML保存成UTF-8编码格式的,然后放到网站的一个目录下,然后你在网站首页或要让浏览器知道的页面代码的<head>部分,插入如下代码:
<link title="搜索 西部硅谷文章" rel="search" type="application/opensearchdescription+xml" href="rss/opensearch.xml" />
请把红色部分修改成你自己的信息。添加后就可以用IE7或FIREFOX查看你添加的页面有什么变化了。