实现 OpenSearch(Tab to Search)功能
在网站上添加了 OpenSearch 功能以后,IE 7.0 和 Firefox 2.0 以上的浏览器就能够在自带的搜索栏里面添加这个网站的搜索功能了。
第一:原始网站支持GET传递参数搜索:
第二:编写 OpenSearch 描述文件:
<?xml version="1.0" encoding="UTF-8"?> <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> <ShortName>Web Search</ShortName> <Description>Use Example.com to search the Web.</Description> <Tags>example web</Tags> <Contact>admin@example.com</Contact> <Url type="text/html" template="http://example.com/?q={searchTerms}"/> </OpenSearchDescription>
第三:添加对 OpenSearch 描述文件的引用:
在网站的模板的 <head> 标记中添加一句:
<link type="application/opensearchdescription+xml" href="opensearch.xml" title="Web Search" rel="search" />