After the opensearch function is added to the website, browsers with ie 7.0 and Firefox 2.0 or above (well, I admit that this function is not found in opera and chrome, but ie 8.0 RC and Firefox 3.05 are absolutely no problem) You can add the search function of this website in the built-in search bar.
To add the opensearch function, there are three steps:
Step 1: implement the opensearch function;
Step 2: Compile the opensearch description file;
Step 3: Add a reference to the opensearch description file.
Then, let's start:
Step 1: implement the opensearch function.
This is the simplest one. If there is a search, you just need to make it support the get parameter transfer.
Assume that you are searching for "ABCD" on the website now, the actual page address is http://example.com /? Q = ABCD
Step 2: Compile the opensearch description file.
You only need to add an XML file to the website. The content is as follows:
1 <? XML version = "1.0" encoding = "UTF-8"?>
2 <opensearchdescription xmlns = "http://a9.com/-/spec/opensearch/1.1/">
3 <shortname> Web Search </shortname>
4 <description> Use example.com to search the Web. </description>
5 <tags> Example Web </tags>
6 <contact> admin@example.com </contact>
7 <URL type = "text/html"
8 template = "http://example.com /? Q = {searchterms} "/>
9 </opensearchdescription>
For ease of description, name the file opensearch. xml and place it in the root directory of the website.
Step 3: Add a reference to the opensearch description file.
This step is also very simple. You only need to add a sentence to the
<Link type = "application/opensearchdescription + XML"
Href = "opensearch. xml" Title = "Web Search" rel = "Search"/>
That's all.
More:
You can provide more settings by modifying the opensearch description file.
Firefox supports the use of the opensearch suggestions plug-in for word-by-word search. To implement this function, you only need to return formatted JSON Data Based on search parameters, and then add the corresponding URL parameters to the description file.
IE support (Firefox also supports) Use opensearch referrer plug-in to add referrer parameters for search.
References:
Opensearch 1.1 protocol
Opensearch Homepage